Copy file based on text tag

Started by iratemonkey, October 14, 2015, 05:15:40 AM

Previous topic - Next topic

iratemonkey

Hi Phil,

When I run from a batch file:

exiftool -r -if "$XMP:Subject eq 'Leopard'" -o "Z:\leopard_exif\leopard_input\%f%-c.%e" "Z:\leopard_exif\leopard_output"

The command prompt appears, prints the above code, along with "Nothing to write".

"Z:\leopard_exif\leopard_input" contains the file I sent you.

Phil Harvey

Ah.  You didn't mention the batch file.

In a windows batch file, all percent characters must be doubled:

exiftool -r -if "$XMP:Subject eq 'Leopard'" -o "Z:\leopard_exif\leopard_input\%%f%%-c.%%e" "Z:\leopard_exif\leopard_output"

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

iratemonkey

Sorry, my bad. I just ran the code you suggest as a batch file and this time the error is:

1 directories scanned
0 image files read


Phil Harvey

OK, we're narrowing things down anyway.  What is the output of this command?:

dir "Z:\leopard_exif\leopard_output"

Oh, wait.  From the directory names it seems you may have the input and output directories reversed.  The output directory should go immediately after the -o (output) option.

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

iratemonkey

Thanks Phil! You are right. Somewhere in my trial and error I must have switched the order of the input and output directories. The following code just worked:

exiftool -r -if "$XMP:Subject eq 'Leopard'" -o "Z:\leopard_exif\leopard_output\%%f%%-c.%%e" "Z:\leopard_exif\leopard_input"

Thanks again so much! A bit more beer money is on its way to your account as a small thank you for your time and help.

Sam

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

iratemonkey

You're welcome. I also noticed that I was sometimes adding a \ to the end of the input directory path, which stopped it from working. So:

exiftool -r -if "$XMP:Subject eq 'Leopard'" -o "Z:\leopard_exif\leopard_output\%%f%%-c.%%e" "Z:\leopard_exif\leopard_input\"

did not work, while:

exiftool -r -if "$XMP:Subject eq 'Leopard'" -o "Z:\leopard_exif\leopard_output\%%f%%-c.%%e" "Z:\leopard_exif\leopard_input"

did work.

Phil Harvey

Right.  Another Windows feature.  Backslash before a quote is special.  This is explained by StarGeek in this post.

Presumably this wouldn't be a problem if you used forward slashes (which are perfectly acceptable to ExifTool).

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