How to batch move extra JPGs from a tree structure that contains JPG/RAW pairs

Started by richimages, November 05, 2013, 10:23:02 AM

Previous topic - Next topic

richimages

Have a question:  Want to see if I can avoid writing code and performing a batch operation that may or may not be a common request.

I have used exiftool to create a master collection of photographs and organize them in to YYYY_MM/ list of directories from 2000_01 to 2013_11.    ( LOVE EXIFTOOL, a wonderful help in eliminating  duplicates )
I have also named photos according to a template of YYYYMMDD_H:M:S_DSC_XXXX.EXT.    I am on mac OS X, latest mavericks version.   

Here's the question:

Before importing stuff into iPhoto, I wish to prep a bit in moving any extra JPG for which I already have an existing NEF file.   But I do not want to do that if the JPG is the ONLY file (I.e.  I have a camera that can take raw and jpg simultaneously for each shot ... and I often used that feature ... but not always. So, for some images I have a JPG/NEF pair ... for those cases, I'd like to move the extra JPG into a MasterRepositoryJGP_Tree )

Is there a way to use the -if construct of the command line executable to do this?


Phil Harvey

People insist on using ExifTool for tasks that it wasn't designed for... ;)

I have come up with a couple of ways to do this:

1) very sneaky:

exiftool -tagsfromfile %d%f.nef '-directory<${filename;$_=""}DSTDIR' -ext jpg SRCDIR

This command will move only JPG files that have NEF counterparts from SRCDIR to DSTDIR.

It works because setting the directory name will fail if the NEF doesn't exist because we are copying it from the FileName tag of the NEF.  I use the FileName tag because it will exist for any file, and set it to the empty string because I'm not actually using its value.

2) a bit simpler (I should have thought of this one first):

exiftool -srcfile %d%f.jpg -filename=DSTDIR/%f.jpg -ext nef SRCDIR

I also tried this, which I thought should have worked:

exiftool -srcfile %d%f.jpg -directory=DSTDIR -ext nef SRCDIR  <-- didn't work with ExifTool 9.39

...but it renamed the NEF to .jpg.  This could be a bug in ExifTool.  I'll have to think more about this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

richimages

Phil ... I love using your software ... and my wanted to say a quick thank you for this ...  I do not think I could have ever gotten organized with the original images I had without this tool.  I now only have 26K **Unique** images ... (no telling how many I had before that included several duplicates !!!  )

So very thankful for your PERSISTENCE  as well ... another person may have become board with such an accomplishment of exiftool and simply obtained a "been there, done that" attitude ... leaving it to slowly degrade from lack of maintenance.  You, however, have obviously spent tireless time in keeping up with exiftool on a consistent basis ...   How did you obtain such a non-human quality of that kind of dedication?  I'll never know ... but, speaking from the whole community of those that use exiftool ... we are very appreciative !!!

:D

And, thanks so much for a quick response ... ( I was afraid that this question was one that had been asked before )

richimages

forgot to ask ... are you solutions case sensitive for the extensions   I believe all my extensions are all cap ... but there may be some that are not that are mixed in for starting years ?

Phil Harvey

Thanks for the kind words.

The -srcfile argument and the FileName strings are case sensitive.  The -ext extension is not.  You will have to run the command multiple times with different -srcfile arguments if necessary to cover the different JPG case variations on a case-sensitve filesystem.

And I have come to the conclusion that this should have worked:

exiftool -srcfile %d%f.jpg -directory=DSTDIR -ext nef SRCDIR

This bug will be fixed in version 9.40.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).