This short, simple script:
do shell script "date +%Y-%m-%d\\ %H:%M:%S\\ %z"
2017-09-13 15:27:41 -700
(That's just an example, of course)
- I don't want the "20" from "2017" so I'll change the %Y to %y
- I don't want dashes
- I don't want colons
- I don't want spaces
- I don't want seconds
- I don't want zone
My script ends up like this:
do shell script "date +%y%m%d%H%M"
and my replacement output is now:
1709131527
(Optionally, I've created an additional service that includes the seconds, useful for rapid renaming of multiple photos or other files I like to store chronologically/sequentially.)
Assign a keyboard shortcut by turning it into a Service in Automator.
- Open Automator.app
- Create a New > Service
- Set it to receive selected text in any application
- Check the Output replaces selected text tick-box
- Insert the Run AppleScript action
- Copy and paste the above AppleScript
- Press Run to make sure it works
- Save the .workflow file to ~/Library/Services
- Open the Keyboard > Keyboard Shortcuts system preference pane, select Services in the left column, then find the Service you just created.
- Assign a keyboard shortcut.