Renaming syntax

Started by Theo, January 18, 2022, 06:44:40 PM

Previous topic - Next topic

Theo

Hi all,
sorry for maybe a trivial question. I'd like to rename the files by shuttercount in six-digit format (eg. 012345), but I can't figure out the correct pattern. Can someone please help me? Thanks.

exiftool -if "${ShutterCount}" "-FileName<${ShutterCount}_%f%E" -r .

StarGeek

From this previous post

"-Filename<${ShutterCount;$_=sprintf('%06d',$_)}"_%f%E"

"-Filename<${ShutterCount;$_=substr('000000'.$_,-6)}"_%f%E"

"-Filename<${ShutterCount;$_='0' x (6-length).$_}"_%f%E"

Plus a new one userful for padding multiple occurances of numbers already part of a string (e.g. "7 of 9" -> "007 of 009"), a variation of the first one.  Not as useful for this purpose, but adding it so I can link to this post at a later date.
"-Filename<${ShutterCount;s/([0-9]+)/sprintf('%06d',$1)/ge}"_%f%E"
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Theo

Totally did it. Thank you for the quick answer!