Rename only the first time but do it much faster

Started by Luuk2005, September 02, 2020, 10:17:00 AM

Previous topic - Next topic

Luuk2005

Greetings, Im try helping on another forum to put exif date in front of filename but need to make easy batch so they just click it and not to worry anymore.
Much of the problem is that it should only rename a filename on the very first time only.
Like if we have 'aaa.cr3' and we need to make it "2020-12-07 aaa.cr3' but never to create '2020-12-07 2020-12-07 aaa.cr3' if you click the batch so many times.
Its working but is very very slow so that I cant even hope for using -r until I fix the problem so here is command:

exiftool -if "not ${filename;s/^(\d+)-(\d+)-(\d+).*/\1\2\3/} eq ${DateTimeOriginal#;s/^(\d+):(\d+):(\d+).*/\1\2\3/}" -"FileName<$Exif:DateTimeOriginal" -d "%Y-%m-%d %%f.%%e" "C:\Test\*.cr?"

Its for standalone exiftool v11.38 without Perl, on Win8.1-64bit. Im need the -if to study the name and arrest having too many dates in the front.
So if filename already have correct exif dates, exiftool then goes to study the next file instead. Sorry for my english is not perfect, but this is what Im hoping for to conclude...

aaaaaaa.cr3 --------> 2020-12-07 aaaaaaa.cr3
19bbbbbbbb.cr3 ---> 2018-01-31 19bbbbbbbb.cr3
2020-12-07 aaa.cr3 --> nothing, go study next .cr3 file (unless 2020-12-07 is counterfeit exif date)

Please any suggestions or testimonials to make it much faster is much appreciated.
Here is what I try: -fast, -n but DateTimeOriginal# should be enough, and converted to batch with double %% everywhere, but still it is very slow.
I dont try Perl version because maybe photographers dont want it, but if much faster I think its worthy effort.

Thanks for such good application because it helps many people. I learn much here but never ask because it ruins the surprise, but this puzzle I cant assemble!
I was strive to have another -if that destroys bad dates at the front, but not unless I can make it much faster, so thank you again!
Windows8.1-64bit,  exiftool-v12.84(standalone),  sed-v4.0.7

StarGeek

Your command looks good, so as long as you're not looping the command in a batch file (see Common Mistake #3), it's probably going as fast as possible.  If your .CR? files are very large, then it's going to take time to open them and parse the data.

You won't be able to recurse with this command, though because you can't use wildcards to recurse (see Common Mistake #2).  You'll have to change
"C:\Test\*.cr?"
into
-ext cr2 -ext cr3 -ext crw C:\Test
* 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).

Luuk2005

Thanks much to StarGeek, because Im very tired to try so many different things, that dont make a faster rename.
Im not realize that .cr2/3 can put exif so far in the middle, so we need laws to prosecute ALL metadata must be near the beginning!
Blessings for the reply.
Windows8.1-64bit,  exiftool-v12.84(standalone),  sed-v4.0.7