Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator Workflow Copying Files

I'm an amateur photographer who takes ~300 outdoor portrait pictures in each set a few times a week. When I do, I shoot in both raw and jpg. I use jpg so I can open all the images when I return home and quickly go through to delete the 50+% of them that don't make the first round of cuts. I open all the jpg images in Preview and Command-Delete the poor-quality photos quickly. I use jpg in conjunction with Preview because I can open all 300+ of them within about 3 seconds (as opposed to opening all 300 in raw, which sometimes takes very long). In addition to the initial load-time, many times I need individual pictures to load quickly (less than a second) as I scroll through them so that I can quickly and more easily determine the difference between two similar photos. When I delete in Preview, the jpg files also move from finder to the trash. So far so good.


Once I've got it narrowed down to the 30-40% of photos I want to work with, I go to finder, sort by name, and delete the raw files that don't have the same file name (with the jpg file extension) by hand. Much time is spent doing this several times a week.


Below is a short example of what Finder looks like just after I delete my first batch.

DSC_1107.JPG

DSC_1107.NEF

DSC_1108.NEF

DSC_1109.NEF

DSC_1110.JPG

DSC_1110.NEF

DSC_1111.NEF

DSC_1112.NEF

DSC_1113.NEF

DSC_1114.NEF

DSC_1115.JPG

DSC_1115.NEF

DSC_1116.NEF

DSC_1117.JPG

DSC_1117.NEF

DSC_1118.NEF

DSC_1119.NEF

DSC_1120.NEF

DSC_1121.JPG

DSC_1121.NEF

DSC_1122.JPG

DSC_1122.NEF

DSC_1123.NEF

...


Once I reach this step in the process, I'd like to use Automator to do the following:

Delete all NEF (raw) file extensions that do NOT have the same file name in conjunction with the jpg file extension.


I would appreciate a walk-through as to how to handle this.


OS X 10.10 (Yosemite)

MacBook Pro (Retina, 13-inch, Late 2013)

2.8 GHz Intel Core i7

16 GB 1600MHz DDR3

Automator

MacBook Pro (Retina, 13-inch, Late 2013)

Posted on Nov 25, 2014 10:37 AM

Reply
Question marked as Best reply

Posted on Nov 25, 2014 11:58 AM

User uploaded file


The Run Shell Script Action is:


for f in "$@"

do

if [ ! -f "${f%.*}".jpg ] ; then

rm "$f"

fi

done



If you prefer to move to Trash instead of deleting with rm (deleting cannot be undone) use:


for f in "$@"

do

if [ ! -f "${f%.*}".jpg ] ; then

mv "$f" $HOME/.Trash

fi

done

7 replies

Nov 25, 2014 12:14 PM in response to Tony T1

Fantastic! Many thanks. I ran with my wife sitting next to me and she asked: "So is this an apple employee that answered that?" And I was like: "No, these people are just geniuses who answer these questions just because. My last question is this: Where could I start to learn how to do other things like this? All I know is a little C++. Should I start with basic Unix commands? Any resources appreciated. Again, thank you.

Nov 25, 2014 12:30 PM in response to Sam-G

Sam-G wrote:

My last question is this: Where could I start to learn how to do other things like this? All I know is a little C++. Should I start with basic Unix commands? Any resources appreciated. Again, thank you.


Glad it worked.


For Automator. here's some good sites:

http://automator.us/resources.html

http://www.macosxautomation.com

http://www.macosxautomation.com/services/download/index.html

http://macosxautomation.com/yosemite/index.html


As OS X is 'built on UNIX", you can run bash scripts and unix commands from Terminal (in Applications/Utilities), or wrapped in Automator like I did above.

Automator Workflow Copying Files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.