in general, if you have similar filename that changes in some particular place, you can set those differences in [] brackets:
ruslanas@ruslanas test]$ ls
a.jpg a.raw a.doc
[ruslanas@ruslanas test]$ ls a.{jpg,raw}
a.jpg a.raw
[ruslanas@ruslanas test]$
or just use asterisk if you have only jpg and raw extension and only those 2 extensions.
also, if you would like to use a singleliner to extract jpg from raw and then move raw to raw dir:
cd /path/to/fresh-photos && ls *raw | while read line ; do culling $line -output /path/to/processed/jpg/$(echo $line | sed 's/raw$/jpg/g') && mv $line /path/to/processed/raw ; done
just replace culling with your cooler and should be good to go!
Also disadvantage of previous line, that you have to have temp dir for new files... Also there is a simple way to make it only do culling to non processed jpg's:
RAW=/path/to/raw && JPG=/path/to/jpg && find $RAW $JPG -type f \( -name '*.raw' -o -name '*.jpg' \) -exec basename {} \; | sed -e 's/\.jpg$//g' -e 's/\.raw$//g' | sort -n | uniq -u | while read line ; do echo "processing ${RAW}/${line}.raw" && culling ${line}.raw -output ${JPG}/$line.jpg ; done
Again, replace culling with our cuddling command.
If you need just remove photos from RAW which are not present in JPG dir:
RAW=/path/to/raw && JPG=/path/to/jpg && find $RAW $JPG -type f \( -name '*.raw' -o -name '*.jpg' \) -exec basename {} \; | sed -e 's/\.jpg$//g' -e 's/\.raw$//g' | sort -n | uniq -u | while read line ; do echo "Removing: ${RAW}/${line}.raw" && rm -f ${RAW}/${line}.raw ; done
keep in mind all extensions expected to be lowercase, if not change to what is in your side.
Before first release, run this test command:
RAW=/path/to/raw && JPG=/path/to/jpg && find $RAW $JPG -type f \( -name '*.raw' -o -name '*.jpg' \) -exec basename {} \; | sed -e 's/\.jpg$//g' -e 's/\.raw$//g' | sort -n | uniq -u | while read line ; do echo "Removing: ${RAW}/${line}.raw" && echo rm -f ${RAW}/${line}.raw ; done
Also, if you will be putting it into script.bash
file, then replace &&
and ;
with enter
s/new lines. For more readable text.