ExifTool Forum

ExifTool => Newbies => Topic started by: jeffayn on November 12, 2019, 09:32:39 PM

Title: change file modified date according to file name
Post by: jeffayn on November 12, 2019, 09:32:39 PM
I am interested to find out is there anyway we can change the date taken or date modified according to file name in batch, because i know how to do it 1 by 1, but not in batch...

any script I can try ?
Title: Re: change file modified date according to file name
Post by: Phil Harvey on November 12, 2019, 09:56:05 PM
This is and example command that will work depending on the format of your file name:

exiftool "-datetimeoriginal<filename" "-createdate<filename" DIR

FAQ 5 (https://exiftool.org/faq.html#Q5) explains the date/time formatting in the file name that ExifTool will accept.

- Phil
Title: Re: change file modified date according to file name
Post by: StarGeek on November 12, 2019, 09:57:27 PM
No script necessary.  In fact, using exiftool in scripts which loop through files is a Common Mistake (https://exiftool.org/mistakes.html#M3).  If you have a command that works on a properly on a single file, just give it the directory name, using a dot as the directory name to indicate the current directory.  You can give exiftool multiple directories at once or even mix directories and individual files.  You add the -r (recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse) to recurse into subdirectories.  If you want to limit processing to specific file types while recursing, then you need to add the -ext (extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension) because wildcards don't really work  with the -r option (see Common Mistake #3 (https://exiftool.org/mistakes.html#M2)).