Setting timestamp for files based on the date contained in their filename

Started by lanceloz, September 05, 2013, 05:51:26 PM

Previous topic - Next topic

lanceloz

Hi there,

I have a bunch of files (approx. 500) with the same name pattern, that is : name_CreationDate.pdf. For instance: invoice015_2013_06_25.pdf or invitation035_2012_11_30.pdf. The last 10 digits are always the creation date. The original timestamps of the files have been messed up by a batch application which set them all to the same day; therefore they mean nothing anymore.

Is there a way to automatically set the timestamp (for instance the "Creation Date" one) to the date indicated in the filename with ExifTool? Is their a way to run this as a batch?

Thanks,

Phil Harvey

a command to do this could be:

exiftool "-filemodifydate<${filename;$_=substr($_,-14,10)} 00:00:00" DIR

where DIR is the name of a directory containing the images.  If you are in Windows, you can also write FileCreateDate in the same command with a similar argument.  If you are on Mac or Linux, use single quotes instead of double quotes.

- 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 ($).