When running the following AppleScript (other portions were removed for clarity)…
set newDate to "1/1/1953 00:00 AM"
do shell script "SetFile -d " & quoted form of newDate & " " & quoted form of filePath
I can change the created date to any year from 1970 to 2079 but attempting any year outside that range returns unpredictable results. For instance, using 1/1/1953, the created date became February 6, 2096. But if I enter 1/1/2096 the created date becomes September 3, 2061. Any year between 1970 and 2079 yields the correct result.
So, what’s the workaround? I need to be able set the year to any date from 1920 to the present and SetFile apparently can’t handle that range.
Post
Replies
Boosts
Views
Activity
I've created an AppleScript to change the file creation dates for several hundred scanned images so that the dates reflect the actual date the photo was taken and not the date the image was scanned.
The script is as follows:
tell application "Finder"
set selectedFiles to (get selection)
repeat with i from 1 to count of selectedFiles
set thisFile to item i of selectedFiles
set thisName to name of thisFile
set yy to first word of thisName
set newDate to yy & "01010101.01"
do shell script "touch -t " & newDate & " " & quoted form of POSIX path of thisName
end repeat
end tell
When I run the script against one test file, I get the following: error "Finder got an error: touch: /1953 front of house.jpg: Read-only file system" number 1
Apparently the shell script is failing because the file is considered read only. I haven't tried it but I'm assuming the shell command would also fail from a terminal session.
The folder and file permissions are set to read/write so I can't figure out why the script is failing or develop a workaround.
Any advice would be greatly appreciated.