So a Default Folder X user just emailed and asked this:
I have been a Mac user for 30 years and would love to find a tool that allows me to click a button (or make this the default filename) while in the “Save…” dialog box that will prepend a formatted date to the beginning of the filename. like so:
Now, you can set up an AppleScript to do this using Default Folder X’s
SetSaveName verbs. However, that would require that you run the AppleScript whenever you want the date prepended, which is a bit of a pain if you want all of your filenames formatted this way. But I realized as I was replying that you can actually automate this by using (or rather, slightly abusing) an existing feature in Default Folder X.
Default Folder X has the ability to run an AppleScript to determine the location of an application’s default folder. The script will be run whenever a new file dialog is displayed by an application, which is the perfect time to do our little filename modification. So I wrote an AppleScript that looks like this:
on getDefaultFolder(appName, dialogType, firstTime) -- only do this for save dialogs if dialogType is "save" then -- get the current date set dateObj to (current date) -- then format it as YYYY-MM-DD set theMonth to text -1 thru -2 of ("0" & (month of dateObj as number)) set theDay to text -1 thru -2 of ("0" & day of dateObj) set theYear to year of dateObj set dateStamp to "" & theYear & "-" & theMonth & "-" & theDay -- then prepend that to the name in the save dialog tell application "Default Folder X" set theName to GetSaveName set theName to dateStamp & " " & theName SetSaveName theName end tell end if -- finally, don't give Default Folder X a default -- folder, so it just continues on normally return "" end getDefaultFolder
If you save this script in a file named “GetDefaultFolder.scpt” in this location:
It will magically prepend the date in the format ‘2020-09-15’ to the beginning of all of your filenames in Save As dialogs. Note that you can still edit the name afterwards if the default filename (like “Untitled 4”) needs to be modified.