I have hundreds of imported video clips that have the date that the video was taken set as the filenames, unfortunately, the creation and modification dates are all incorrect since they were set as the files were imported. I was hoping to set the creation and modification dates to the dates that the video was actually taken. As I mentioned, this information is written in the filename in this format: YYYYMMDDhhmmss.mov. I have found the script below that allows me to manually change the information faster than other options I’ve found, but it would be awesome if I could just drop the file or preferably a group of files onto the application and have the data taken from their respective filenames and set to the creation and modification dates. Any help would be greatly appreciated!
on open files_
display dialog "enter the new creation date in format YYYYMMDDhhmm.ss ex: 200112251730.34:" default answer "" buttons {"Cancel", "Continue"}
copy the result as list to {the new_creation_date, the button_pressed}
repeat with file_ in files_
tell application "Finder"
set file_ to POSIX path of file_
do shell script "touch -t " & new_creation_date & " " & quoted form of file_
end tell
end repeat
end open
Hi, I’ve had much trouble in the past using “touch” to set the creation and modification dates on files. As such I wrote a command line tool to set those dates. You might want to use it and can download it here. Here’s a droplet script you can use with that tool. Note: make sure you have the path to the tool properly set in the code. I wrote it for the tool to be on your desktop.
on open theFiles
-- path to the unix executable
set changeFileDatesPath to (path to desktop folder as text) & "ChangeFileDates"
repeat with aFile in theFiles
-- get file name
tell application "Finder" to set fileName to name of aFile
-- extract the date values from the file name
set theYear to text 1 thru 4 of fileName
set theMonth to text 5 thru 6 of fileName
set theDay to text 7 thru 8 of fileName
set theHour to text 9 thru 10 of fileName
set theMinutes to text 11 thru 12 of fileName
set theSeconds to text 13 thru 14 of fileName
-- define the dates
set creationDate to theMonth & "/" & theDay & "/" & theYear & space & theHour & ":" & theMinutes & ":" & theSeconds
set modificationDate to creationDate
-- set the dates
do shell script quoted form of POSIX path of changeFileDatesPath & " -cDate " & quoted form of creationDate & " -mDate " & quoted form of modificationDate & " -file " & quoted form of POSIX path of aFile
end repeat
end open