change date created and modified based on date in file name

Post any Bulk Rename Utility support requirements here. Open to all registered users.

change date created and modified based on date in file name

Postby Script8647 » Sat Jun 17, 2023 8:31 am

Hi,
I have a bunch of files (photos and videos) that have dates at the beginning of the file name (eg. 01-06-2023-0h9ufkbsow5n0lro7gjdd_source.mp4, 01-12-2023-1280x959_9ba4543799ea9325e4df8a3c24f73ab4.jpeg) but the date created and modified does to match the date at the beginning of the file. How would I take just the date part of the file name and then change the date created and modified? The time does not matter I'm only looking to change the date. I tried looking through the form for something on how to do this but couldn't find anything unless I missed it.
Script8647
 
Posts: 2
Joined: Sat Jun 17, 2023 8:11 am

Change date-stamps from filename

Postby Luuk » Sun Jun 18, 2023 9:40 am

I dont believe that "Change File Stamps" inside of Special(14) can ever look at the filename characters?
There is a free exiftool.exe to change them like your description, but its a command-line application.
This some examples, depending on how it should also conduct the times??

Code: Select all
"C:\Path\To\exiftool.exe" -fast4 -overwrite_original -if $filename=~/^\d\d-\d\d-20\d\d/ -File:System:Time:All"<${filename;s/(..)-(..)-(.{4}).*/$3:$1:$2 00:00:00/}" "C:\PathTo\YourFolder"
After getting the date from $filename, this uses 00:00:00 for the time.

Code: Select all
"C:\Path\To\exiftool.exe" -fast4 -overwrite_original -if $filename=~/^\d\d-\d\d-20\d\d/ -File:System:Time:All"<${filename;s/(..)-(..)-(.{4}).*/$3:$1:$2/} ${FileCreateDate;s/.* (\d\d:\d\d:\d\d).*/$1/}" "C:\PathTo\YourFolder"
After getting the date from $filename, this preserves the original time.
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: change date created and modified based on date in file name

Postby Script8647 » Tue Jun 20, 2023 6:24 am

Thank you. This does exactly what I was looking for.
Script8647
 
Posts: 2
Joined: Sat Jun 17, 2023 8:11 am


Return to BRU Support