Random screenshot names on Mac OS X
With services like Dropbox coming now with cool automated Screenshot sharing features, it’d be also nice to :
- Reduce the screenshots in size, so they don’t eat more space than necessary
- Be able to simply shorten the screenshot names on Mac OS, so they aren’t saved every time as
Screenshot 2014-02-18 19.45.38.png– especially since we know the screenshot date from the creation time
It’s a bit tougher than anticipated, but we have a solution nevertheless. You will need to enter the
Terminal on Mac OS, which you can easily find in your finder.
Reading current Screenshot options on Mac OS X
With the command
defaults read com.apple.screencapture you can see your current options.
Changing the screenshot type
Let’s change the screenshot type from PNG to JPG. That will give us a much nicer filesize saving, which you can benefit from more and more the higher your resolution. This will also keep our Dropbox size smaller. Simply type into the terminal the following :
defaults write com.apple.screencapture type jpg
All commands should be followed by the enter key.
Remove date from screenshot name on Mac OS X
With the following command, we can remove the part which automatically adds the date to the screenshot name automatically. So Screenshot 2014-02-18 19.45.38.jpg would become Screenshot.jpg ( and Screenshot(2).jpg, Screenshot(3).jpg, etc. ) but we’ll get to that in a second.
defaults write com.apple.screencapture "include-date" 0
Change the Screenshot name on Mac OS
Now let’s change the base name of the Screenshot, the Screenshot.jpg part itself. You can do that by simply running :
defaults write com.apple.screencapture name screen
And all new screenshots would start with screen. However, it’s not so nice to have a lot of filenames in the format :
screen.jpg screen(2).jpg screen(3).jpg
Randomize the Screenshot name on Mac OS X
So what we like to do here, is giving them a random 3 letter filename every minute. For that we’ll use the inbuilt
openssl rand feature in a cronjob.
For that we’ll have to edit the cronjob, by typing in
crontab -e. The
vim editor will pop up. Press
A, to switch to insert mode, then scroll down with the cursor keys, and add the following new line at the bottom :
* * * * * /usr/bin/openssl rand -base64 3 | xargs defaults write com.apple.screencapture name
When you’re done typing, press the Escape key, and type :
:wq to save the file and quit the editor.
One last thing
In order to load the settings, we’ll have to restart the SystemUIServer, which can be done easily with the killall command. The Server will restart itself immediately :
You’re done! You can close the terminal window now by typing in
Every time you create a new screenshot, it will save it as
bQd.jpg – short, unique and much nicer to share over the internet – at least for us.
by Markus Stefanko