Thread

Posted on Mon Jul 23 22:14:18 2007 by oozy
Checking image width then rename the filw as imagewidth_%f.%e
I want to check a bunch of image and rename them as imagewidth_%f.%e I tried the following but not help
exiftool -if '$imagewidth<9999' -q -t -S -filename='$imagewidth'_%f.%e -r .
Direct Responses: 5803 | Write a response
Posted on Mon Jul 23 23:37:39 2007 by exiftool in response to 5802
Re: Checking image width then rename the filw as imagewidth_%f.%e
Close, but '=' is used to assign the value of a tag. You actually want to copy the value from another tag (ImageWidth), so you should use '<' instead. ie)

exiftool -if '$imagewidth<9999' -q -filename'<$imagewidth'_%f.%e -r .

I have also taken out the -t and -S because these are only meaningful when reading information.

Read the "COPYING EXAMPLES" section in the application documentation for more examples of copying tags.

- Phil
Direct Responses: 5804 | Write a response
Posted on Mon Jul 23 23:41:01 2007 by exiftool in response to 5803
Re: Checking image width then rename the filw as imagewidth_%f.%e
Ooops, sorry. There was another problem: %f and %e only work when a filename is expected, which it isn't when copying tags. Also, I needed braces around 'imagewidth' because it was followed immediately by an underline (which is a valid character in a tag name). So instead you need to do this:

exiftool -if '$imagewidth<9999' -q -filename'<${imagewidth}_$filename' -r .

- Phil
Direct Responses: 5805 | Write a response
Posted on Mon Jul 23 23:44:58 2007 by exiftool in response to 5804
Re: Checking image width then rename the filw as imagewidth_%f.%e
Note to self: No more quick replies.

OK. So %f and %e will work in this case, because a file name is expected for the filename tag. duh. silly me. Usually this syntax doesn't expect a filename (as something like '<=' does), but when the tag is 'FileName' there is an exception.

Sorry about adding to the confusion.

- Phil
Write a response