How do you change the format of the OSX Screen Shot file name? I'd like my screen shots to only be named with the current date time, preferably in a format like:

2016-09-02-16:02:48


How should I go about doing this?

So far I've tried inserting an empty string into com.apple.screencapture name

as shown:

$ defaults write com.apple.screencapture name ""
$ killall SystemUIServer


But OSX is still inserting a space as shown below:


So there's two problems I'm having:


How do I change the date time format so there are no spaces?
How do I make sure there is no leading space in the screenshot filename?


Thanks :)
You neither can rename a file to the proposed name - it contains several colons (:) which are reserved (= forbidden) characters in the HFS+ file system - nor does defaults write com.apple.screencapture ... allow a different date format.

One idea though is creating a launch agent to rename all files in a dedicated folder starting with "Screen Shot ...":

A very simple solution, assuming you restore the default naming convention for screenshots and replace user_name by your short name below, is then:

Create a file named "screencaprn" in e.g /usr/local/bin with the content:

#!/bin/bash

mv /Users/user_name/Desktop/Screen\ Shot*.png /Users/user_name/Desktop/"`date "+%Y-%m-%d-%H.%M.%S"`.png"; $2&gt;/dev/null


Change permissions:

chmod +x /usr/local/bin/screencaprn


Then create a launch agent in ~/Library/LaunchAgents with the name "usr.screenshot.rename.plist"  and the content:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;usr.screenshot.rename&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/bin/bash&lt;/string&gt;
        &lt;string&gt;-c&lt;/string&gt;
        &lt;string&gt;/usr/local/bin/screencaprn&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;WatchPaths&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/Users/user_name/Desktop&lt;/string&gt;
    &lt;/array&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Then load the plist with:

launchctl load ~/Library/LaunchAgents/usr.screenshot.rename.plist


This works but has a delay of up to 10 seconds (thus changes the seconds and sometimes the minutes of the original named screenshot file e.g. Screen Shot 2016-09-03 at 03.24.02.png to 2016-09-03-03.24.05.png) and adds one com.apple.xpc.launchd[1] (usr.screenshot.rename): Service only ran for X seconds. Pushing respawn out by Y seconds. line to the system log.