I'm trying to create an AppleScript to create a new WriteRoom file with the current date and time as its title. In fact this is for my diary entries (it is so important that I record my wild hedonist lifestyle spent partying with international superstars).
I am using Mac OS 10.8.2.
I think the problems I am encountering relate to sandboxing and/or versioning. I've done quite a bit of googling and the script at present is as follows:
set yr to year of (current date)
set mt to month of (current date) as number
set dy to day of (current date)
set hs to hours of (current date)
set ms to minutes of (current date)
set sc to seconds of (current date)
set theDate to yr & "-" & ¬
(characters -2 through -1 of ("0" & mt)) & "-" & ¬
(characters -2 through -1 of ("0" & dy)) & " " & ¬
(characters -2 through -1 of ("0" & hs)) & "-" & ¬
(characters -2 through -1 of ("0" & ms)) & "-" & ¬
(characters -2 through -1 of ("0" & sc)) ¬
as text ¬
set path2Doc to "boss HD:Users:pat:Documents:Diary:Latest:" as text
set newName to (theDate & ".rtf") as text
tell application "System Events"
make new file at end of folder path2Doc with properties {name:newName}
end tell
set newFile to (path2Doc & newName) as alias
tell application "WriteRoom"
activate
make new document with properties {name:newName}
save document 1 in newFile
end tell
This creates a new document opened with the date/time name but there is a big problem.
However, it is obvious that I wish to just write straight into the opened document, not have to close it and reopen it.
If I change the line:
tell application "WriteRoom"
to:
tell application "TextEdit"
the behaviour is the same except now of course I am dealing with a TextEdit document.
Thank you.