I recently received a lot of pictures from my sister’s new DSLR camera. After I saved the pictures, I noticed that she had the time set to PM instead of AM, and the day before the current date. This causes them to be out of order with other pictures taken at the same time with another camera and for archival purposes, i would like to have them all in chronological order.
I created a script to increment the creation date of the images by 12 hours so that it will correct the mistake, but I am having trouble getting the date into the correct format to send the touch command. If anyone could help, it would be greatly appreciated!
Thanks!
set theFile to (choose file)
tell application "Finder"
set oldDate to creation date of theFile as date
set newDate to (oldDate) + 12 * hours
--set newTime to time string of (newDate)
end tell
display dialog "the current timestamp is: " & oldDate & ". The new file will be changed to: " & newDate
do shell script "touch -t " & newDate & quoted form of POSIX path of theFile
-- return (info for theFile)
the touch command does not change the creation date, only the access and modification date.
It expects the date paramter in format [CC]YYMMDDhhmm[.SS], Century and Seconds are optional.
And there is a space character required before the file path
Thanks Stefan, that looks like it will work perfectly for me.
Here is the much simpler version.
set theFile to (choose file)
tell application "Finder"
set oldmodDate to the modification date of theFile as date
display dialog "the old timestamp is: " & oldmodDate
end tell
do shell script "touch -A 120000 " & quoted form of POSIX path of theFile
tell application "Finder"
set newmodDate to the modification date of theFile as date
display dialog "the modification time was changed from: " & return & return & oldmodDate & return & return & "to" & return & return & newmodDate
end tell