Applescript to Edit Date Created and Date Modified

Hi Michael,

I’m giving the trial of EagleFiler a shot, and am wondering if there is the Date Created and Date Modified Fields are editable via Applescript.

I’m trying to transfer a bunch of files from Scrivener to EagleFiler. Scrivener doesn’t appear to preserve the created/modified dates when exporting files to Finder.

All of my filenames begin with the date in the form “2011.02.27 - Title Here, Hyaa”. I want to use an applescript to go through each file, read the date at the front of the file name, and use it for the Date Created and Date Modified fields. I did a quick search of your forums and applescript page, but couldn’t find what I was looking for.

Thanks. Sam.

They are. There’s an example of this in the Web archive to PDF script.

Yes, this definitely sounds like something that could be done with AppleScript.

Great - thanks, Michael. I’ll check out the script you mentioned and see what I can come up with.

FYI, I find that creating new date objects in AppleScript is a bit confusing because if you write:

date "1/3/1977"

it will only work on Macs that are set to use that date format. So if you are creating a date programmatically, you might want to do something like:

set _date to current date
set year of _date to 1977
set month of _date to 1
set day of _date to 3

Hi Michael,

Thanks for that.

I adapted a script I’d written ages ago for Mori which I’ve attached below if you or anybody else wants to use it. It seems to work so far, though my testing’s been limited. Please feel free to improve/modify/clean it up, as I’m relatively new to scripting and just sort of cobble stuff together with the help of examples I find here and there.

Thanks. Sam.

= = = = = = = = = = = = = = = = = = =

------FOR ENTRIES (IN SELECTED ENTRIES) THAT BEGIN WITH A DATE (IN THE FORM 2011.05.15), COERCE THEIR CREATION & MODIFICATION DATES TO THE DATE CONTAINED IN THE TITLE

tell application “EagleFiler”
set theRecords to selected records of browser window 1
repeat with theRecord in theRecords
set theTitle to theRecord’s title
try
set theDate to (characters 6 thru 7 of theTitle) & “.” & (characters 9 thru 10 of theTitle) & “.” & (characters 1 thru 4 of theTitle) as string
set theDate to my date theDate
set theRecord’s creation date to theDate
set theRecord’s modification date to theDate
end try
end repeat
end tell