Example command lines that changes the default save location of the macOS Screenshot app and tweak other preferences:
mkdir ~/Screenshot defaults write com.apple.screencapture location -string "~/Screenshot" defaults write com.apple.screencapture name -string "screenshot" defaults write com.apple.screencapture include-date -bool true defaults write com.apple.screencapture disable-shadow -bool true defaults write com.apple.screencapture show-thumbnail -bool false defaults write com.apple.screencapture capture-mouse-pointer -bool false killall SystemUIServer defaults read com.apple.screencapture
This results in:
$ ls -1 ~/Screenshot/ screenshot_2005-01-22_at_07.17.34.png screenshot_2013-06-27_at_15.43.08.png screenshot_2017-03-11_at_20.23.31.png screenshot_2021-10-18_at_13.13.14.png screenshot_2022-12-01_at_22.43.18.pngTo undo/revert to the builtin defaults:
defaults delete com.apple.screencapture killall SystemUIServer
LaunchAgent workflow
In the example listing of the ~/Screenshot directory shown earlier, all spaces was replaced by underscore. This is not supported by the screenshot app, but we can utilize
LauchAgents to monitor the ~/Screenshots directory and do any kind of "post-production" on the images and videos as they arrive.
Here is a LaunchAgent Property List (plist), that shows how we might replace the spaces with underscores, as a shell one-liner, but any complex script or program could be called instead:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ScreenshotRename</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>ls -1rt screenshot\ * | xargs -I{} bash -c 'mv "{}" "$(tr " " "_" <<<"{}")"'</string>
</array>
<key>WorkingDirectory</key>
<string>/Users/CHANGE_HERE/Screenshot/</string>
<key>WatchPaths</key>
<array>
<string>/Users/CHANGE_HERE/Screenshot/</string>
</array>
</dict>
</plist>
download:
dk.thrysoee.screenshot_rename.plist
Download the plist, copy it to ~/Library/LaunchAgents, and run the following to activate it:
for c in stop unload load start; do launchctl $c ~/Library/LaunchAgents/dk.thrysoee.screenshot_rename.plist; done