Regular Expression for renaming file?

Started by lnjustin, October 19, 2019, 03:21:52 PM

Previous topic - Next topic

lnjustin

I need to rename files that are (accidentally) named like:
2016-11-11_at_22h55m00056.MTS
YYYY-MM-DD_at_HHhMMmXXXXX.MTS

I need to extract the XXXXX (the last 5 characters before the period/extension). And then rename to:
YYYY-MM-DD_at_HHhMMmSSs_XXXXX.MTS (the seconds need to be added after the minutes)

So it would look more like
2016-11-11_at_22h55m45s_00056.MTS

I know how to do what i need if I would run this on the original file named 00056.MTS. It would be:
/usr/local/bin/exiftool -d /Volumes/video/%Y/%m/%Y-%m-%d_at_%Hh%Mm$Ss_%%f.%%e '-filename<DateTimeOriginal' filename

But now that I ran this command once with the wrong format, I need another command that will simply rename the file. But I don't know how to use regular expressions for this. Help?

StarGeek

One of the advanced options for the %f variable is to grab characters from the end of the filename (excluding the extension).  So try your normal command but instead of %%f, try %%-5f.  Use TestName instead of Filename to test without making changes.
"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

e2b

Where are the advanced options for the %f variable documented, please?

StarGeek

"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