File Renaming to Include Exposure Compensation

Started by ipodzrock, January 03, 2020, 03:15:41 PM

Previous topic - Next topic

ipodzrock

I would like to rename my image files using the "creation date" and including the "exposure compensation" (the last part to more easily filter in Lightroom ... I'm currently doing the following:

  • exiftool -P -a "-FileName<CreateDate" -d "%Y%m%d-%H%M%S%%.lc.%%le" *.[cC][rR]2
  • exiftool '-FileName<%f ($EXIF:ExposureCompensation EV).cr2' *.cr2

The problem that I run into is if the "exposure compensation" is in thirds such as ... Exposure Compensation: -4/3 ...

That ends up creating a directory on MacOS due to the "/" and the file ends up called 3 EV).cr2

I could use a sed command and create a BASH variable to use during the file renaming, but I'm hoping there is a more elegant solution ... in fact, if there is a more elegant solution and a way to combine the two commands I'd be thrilled.

Thanks!

StarGeek

See Advanced formatting feature
   A default expression of tr(/\\?*:|"<>\0)()d is assumed if the expression is empty (ie. ${TAG;}). This removes the characters / \ ? * : | < > and null from the printed value.

So use ${ExposureCompensation;} to remove the slashes.

Also, you might consider using the -ext (extension) option (-ext cr2) to limit processing to CR2 files and a single dot . to indicate the current directory.  If you ever decide to recurse into subdirectories, the asterisk wildcard won't work.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Alan Clifford

Wouldn't using -n in the exiftool command do it?

StarGeek

The output from adding -n appears to be decimal (e.g. 1.5 instead of +3/2) which may not be what ipodzrock wants.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ipodzrock

The -n command does produce this ... 20171027-080604b (-1.333333333 EV).cr2 ... if it was -1.3 that would be okay ... I was thinking something like -4/3 being translated to -4_3?

... adding a semicolon produces nearly the same thing except it looks like 20171027-080604b (-1.333333333; EV).cr2

StarGeek

Quote from: ipodzrock on January 03, 2020, 04:01:24 PM
20171027-080604b (-1.333333333; EV).cr2

Double check your command.  The fact that the semicolon is showing up there means that something is wrong.

But my command would completely remove the slash, resulting in -43.  Use this instead to put an underscore.
exiftool '-FileName<%f (${EXIF:ExposureCompensation;tr(/)(_)} EV).cr2' *.cr2
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Alan Clifford

Quote from: StarGeek on January 03, 2020, 05:05:59 PM

exiftool '-FileName<%f (${EXIF:ExposureCompensation;tr(/)(_)} EV).cr2' *.cr2

Could tr(/)(÷) be used instead or would that character cause problems?

ipodzrock

Sorry for misunderstanding your command ... here is the modified result ... 20171027-080604b (-4_3 EV).cr2

StarGeek

Is that the result you wanted?  Or does it need more tweaking?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

Quote from: Alan Clifford on January 03, 2020, 05:44:51 PMCould tr(/)(÷) be used instead or would that character cause problems?

It might cause problems on Windows due to the usual character set problems, but probably not on Mac.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ipodzrock

This is the result I was looking for ... thank you  :)