I’m racking my brain trying to figure out a how to write a script in Applescript or Keyboard Maestro to rename a record by adding the file creation date at the beginning. I would like to add the date formatted as YYYY.MM.DD along with a hyphen before the original name. The final product should look like this: YYYY.MM.DD - Original Name.
I was just about to post an Applescript that does exactly what I need. It’s a modified version of the one @BLUEFROG posted a link to above.
I tried to paste the compiled Applescript into this post, but the formatting is lost. I’d appreciate the procedure for pasting and preserving the formatting…thanks.
tell application id “DNtp”
repeat with thisRecord in (selection as list)
set recordName to (name of thisRecord)
set creationDate to (creation date of thisRecord)
set thisMonth to texts -1 thru -2 of (“0” & (month of creationDate as number))
set thisDay to texts -1 thru -2 of (“0” & day of creationDate)
set thisYear to year of creationDate
set titleDateString to ("" & thisYear & “.” & thisMonth & “.” & thisDay & " - ")
set name of thisRecord to titleDateString & recordName
end repeat
end tell
repeat with thisRecord in (selection as list)
set recordName to (name of thisRecord)
set creationDate to (creation date of thisRecord)
set thisMonth to texts -1 thru -2 of ("0" & (month of creationDate as number))
set thisDay to texts -1 thru -2 of ("0" & day of creationDate)
set thisYear to year of creationDate
set titleDateString to ("" & thisYear & "." & thisMonth & "." & thisDay & " - ")
set name of thisRecord to titleDateString & recordName
end repeat
end tell