Process files with star rating of one or more

Started by devenh, April 02, 2013, 05:26:33 PM

Previous topic - Next topic

devenh

Phil,

Could you show me how to adapt the following command to process NEF files with a star rating of one or more (or to not process files with zero stars):

exiftool -if '$jpgfromraw' -b -jpgfromraw -w %d%f_%ue.jpg -execute -if '$previewimage' -b -previewimage -w %d%f_%ue.jpg -execute -tagsfromfile @ -srcfile %d%f_%ue.jpg -overwrite_original -common_args --ext jpg DIR

All my images have embedded JPGs, so I don't think I need the previewimage option included.

Could you assume that the source and destination directories are c:\source and d:\dest?

Is it possible for the extracted JPGs to have the same timestamp as the source?  If so -- and I know this is asking way too much  :D -- is there a way to process NEFs that are rated one star or more and whose timestamp is different from the destination JPG (assuming one already exists). 

What I am trying to do here is only process the NEFs that have changed since the last time the files were processed.  I imagine one could look at timestamps, but then one would have to keep track of the last time the files were processed.

Thanks,

Deven


Phil Harvey

Hi Deven,

Tricky.   Let's take it one step at a time.

If you want, your first command can be simplified using the user-defined BigImage tag from the sample config file:

exiftool -bigimage -b  -w d:\dest\%f_%ue.jpg -if "$rating" -execute -tagsfromfile @ -all -filemodifydate -srcfile d:\dest\%f_%ue.jpg -overwrite_original -common_args --ext jpg -if "$rating" c:\source

This should do everything you want (provided that "Rating" is the correct tag, and that the only value you want to ignore is "0"), except that it won't only update files which were recently modified.  This is the difficult part because there is currently no way to compare the values of tags from different files.  The closest I can get is to process only files modified after a certain date.  You will have to enter this date manually, but you can take it from the date/time of the last modified jpg.  To do this, change the -if options to something like this:

-if "$rating and $filemodifydate gt '2013:04:02 08:00:00'"

I realize this is somewhat messy, but it's all I can think of right now.

- 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 ($).

devenh

Phil,

Thanks!  Couple of more questions:

1. What part of the command is selecting the NEF files in the source directory?

2. What is %f_%ue doing?  I understand %f (filename), %d (directory), and %e (extension), but I haven't been able to find and explanation about %ue?

3. Does the destination directory have to exist?  In particular, I am thinking about instances where ExifTool is asked to recurse through a directory structure and you want that structure to be duplicated, but on another drive or different root directory.

Deven

Phil Harvey

Quote from: devenh on April 02, 2013, 08:44:03 PM
1. What part of the command is selecting the NEF files in the source directory?

the --ext jpg selects all but JPG files.  Use -ext nef instead to select only NEF files.

Quote2. What is %f_%ue doing?  I understand %f (filename), %d (directory), and %e (extension), but I haven't been able to find and explanation about %ue?

The "u" gives you upper-case.  So "%ue" is the upper-case extension.  This is all detailed in the -w option documentation.

Quote3. Does the destination directory have to exist?

No.

Also, I forgot to mention:  To update JPG files that already exist, you will need to change -w to -w!.  But don't use the "!" unless you are sure the command is working as intended.

- 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 ($).

devenh

Okay, I am making progress!

I simplified my testing so I am only processing NEF files, outputting JPG files to the same directory, and I broke the process down into separate batch files (rather than combining them with -execute).

So, first extract the JPG's:

exiftool -if "$rating" -jpgfromraw -b -w! %%f.jpg -ext nef .

This works fine.  The resulting JPG files don't have and IPTC or EXIF.  Is this typical or just the case with NEFs?  It seems like it would be convenient to have something like -jpgfromrawwithtags.

Anyway, the tags can be copied with:

exiftool -tagsfromfile %%f.nef -ext jpg . -overwrite_original

No '-if "$rating"' is needed here as the JPGs being processed already passed that test.

The only thing missing is that the resulting JPGs do not have the same timestamp as the NEFs.  I haven't been able to get the -filemodifydate to do anything.

Thanks,

Deven

Phil Harvey

Hi Deven,

Typically, embedded JPEG images in RAW files contain no metadata.  There are exceptions, but NEF isn't one of them.

Adding -filemodifydate after the tagsfromfile option in your last commandn should copy this too from the NEF.

- 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 ($).

devenh

Okay, I did get it to working with:

exiftool -tagsfromfile %%f.nef -ext jpg . -overwrite_original -filemodifydate

Thanks for your help!  Quite a remarkable tool.

Deven

devenh

Well, actually that did not work  :(

So, we have:

1) exiftool -tagsfromfile %%f.nef -ext jpg . -overwrite_original

2) exiftool -tagsfromfile %%f.nef -filemodifydate -ext jpg . -overwrite_original

3) exiftool -tagsfromfile %%f.nef -all -filemodifydate -ext jpg . -overwrite_original

#1 and #3 copy all the tags.

#2 and #3 copy the timestamps

So what is confusing is that adding -filemodifydate to #2 breaks the actual copying of tags.  The -all command needs to be added in #3, but somehow isn't needed in #1.

Deven

Phil Harvey

Hi Deven,

Number 3 copies all tags plus the time stamp.  I think you are mistaken if you say it doesn't work.

Add the -v2 option to see the details about what is written.

- 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 ($).

devenh

Phil,

Perhaps I wasn't clear in my previous post.  I tried to point out that #3 did copy both the tags and the timestamp.

What I am curious about is why adding -filemodifydate to #1 caused the tags to no longer be copied and why the -all option had to be added to #2 to get everything working again?

After giving it some more thought, my best guess is that ExifTool sees the -filemodifydate as a request for a specific tag (although it seems to me to be more of a file attribute) and therefore assumes that is all that is needed.  Adding the -all tag overrides this assumption and tells ExifTool to copy everything.  Did I guess right?

Deven

Phil Harvey

Hi Deven,

I understand your question now.  This is explained in the first paragraph of the -tagsFromFile documentation:

            Copy tag values from SRCFILE to FILE.  Tag names on the command
            line after this option specify the tags to be copied, or excluded
            from the copy.  Wildcards are permitted in these tag names.  If no
            tags are specified, then all possible tags (see note 1 below) from
            the source file are copied to same-named tags in the preferred
            location of the output file (the same as specifying "-all").  More
            than one -tagsFromFile option may be used to copy tags from
            multiple files.


- 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 ($).