Would like to better understand this script...

I am new to this forum. I came to be here whilst looking for a script to change the creation and modification dates on a bath of photos, based on the filename of the photos.

I found a script here that can do this. It’s posted here: http://macscripter.net/viewtopic.php?id=35725

The script is:

set changeFileDatesPath to (path to desktop as text) & "ChangeFileDates"
set movieFolder to choose folder with prompt "Choose the folder with the movies!"

-- get all the files in the folder
tell application "Finder"
   set theFiles to (files of movieFolder whose name extension is "jpg") as alias list
end tell

-- change the creation and modifcation date of every file
repeat with aFile in theFiles
   tell application "Finder" to set thisName to name of aFile
	set theYear to text 5 thru 8 of thisName
	set theMonth to text 9 thru 10 of thisName
	set theDay to text 11 thru 12 of thisName
	set theHour to text 14 thru 15 of thisName
	set theMinutes to text 16 thru 17 of thisName
	set theSeconds to text 18 thru 19 of thisName
   set creationDate to theMonth & "/" & theDay & "/" & theYear & space & theHour & ":" & theMinutes & ":" & theSeconds
   do shell script quoted form of POSIX path of changeFileDatesPath & " -cDate " & quoted form of creationDate & " -mDate " & quoted form of creationDate & " -file " & quoted form of POSIX path of aFile
end repeat

The above includes a few modifications from the original. I changed it to look for jpg rather than mov files. I also changed the “text * through *” parts… to match the filename structure of my images.

I am pretty new to AppleScript. When running the script it gives me the error:

I am not sure why.
I am running the script from within AppleScript Editor.
If I set up a dictory at /Users/jonathan/Desktop/ChangeFileDates I get the error

. So I figured that was not the answer.
I have saved the script to /Users/jonathan/Desktop/ChangeFileDates.sh - thinking perhaps that was what’s necessary. Didn’t help.

So although I am sure this is very simple, I have come unstuck.

I would greatly appreciate a tip to set me in the right direction with making this work.

Thank you,



is an Unix pathname.
AppleScript is unaware of this kind of path.

You must use
POSIX file “/Users/jonathan/Desktop/ChangeFileDates”


(path to Desktop as text) & “ChangeFileDates”

which is my preferred one.

KOENIG Yvan (VALLAURIS, France) samedi 17 août 2013 17:55:28

Hi Jonathan. Welcome to MacScripter.

“ChangeFileDates” isn’t the name of a folder but the name of an executable program written by the author of the script. The script uses it to do the work of changing the files’ creation and modification dates. There’s a download link for it in the note immediately above the script in the other thread.

Thanks Nigel. That did the trick.
Wow. In what seemed like an instant, a whole lot of photos now have the correct dates on them.

I am going to roam around this forum and see what other things I can learn and utilise. It’s time I got my head around AppleScript more than I have since jumping to Mac 3 years ago.

Thank you…


Thanks Yvan,
In this instance, the path of quoted was the output from AppleScript editor. The script itself does in fact utilise the format you have indicated (path to Desktop as text) & “ChangeFileDates”).
Nigel’s answer has set me in the right direction.