Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Apple Script

Is it possible to create an apple script so that when you are saving a document, it is automatically titled with the date that document was produced (in say, the following format 2015_01_01_) and then you can added your own descriptive title manually?


Thanks.

iMac (27-inch Mid 2011)

Posted on May 19, 2015 5:24 AM

Reply
5 replies

May 19, 2015 7:50 AM in response to embolton

Try the following script and tell me if it needs some improvements:


tell application "Finder"

repeat with thisItem in (get selection)

if class of thisItem is document file then

set thisCreationDate to my formatDate(creation date of thisItem)

set thisName to name of thisItem

if not (thisName begins with thisCreationDate) then

set name of thisItem to thisCreationDate & space & thisName

end if

end if

end repeat

end tell


on formatDate(theDate) -- for example: 2015-01-01

set theYear to (year of theDate) as text

set theMonth to (month of theDate) as integer

set theDay to day of theDate

if theMonth < 10 then set theMonth to "0" & theMonth

if theDay < 10 then set theDay to "0" & theDay

return theYear & "-" & theMonth & "-" & theDay

end formatDate

Jun 2, 2015 6:18 AM in response to Pierre L.

Sorry for the delayed reply - thanks so much for this, it works really well, although I have a few queries.


1) How do i set up the apple script so that it will work when I complete a certain key stroke/combination of key strokes in Finder?


2) I've worked out how to set up the apple script using _ instead of - How do I set it up so that there is no space between the date and the title eg. 2015_06_02_Document


Thanks so much.

Jun 2, 2015 6:40 AM in response to embolton

embolton wrote:


Sorry for the delayed reply - thanks so much for this, it works really well, although I have a few queries.


1) How do i set up the apple script so that it will work when I complete a certain key stroke/combination of key strokes in Finder?


2) I've worked out how to set up the apple script using _ instead of - How do I set it up so that there is no space between the date and the title eg. 2015_06_02_Document


Thanks so much.


1) Try FastScripts (free for up to 10 keyboard shortcuts).


2) Just replace space with "_" in the script.

Apple Script

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.