change file modified date according to file name

Started by jeffayn, November 12, 2019, 09:32:39 PM

Previous topic - Next topic

jeffayn

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 ?

Phil Harvey

This is and example command that will work depending on the format of your file name:

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

FAQ 5 explains the date/time formatting in the file name that ExifTool will accept.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

No script necessary.  In fact, using exiftool in scripts which loop through files is a Common Mistake.  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 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 because wildcards don't really work  with the -r option (see Common Mistake #3).
* 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).