Example commands that change the default save location of the macOS Screenshot app and tweak its 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 these changes and revert to the built-in defaults:
defaults delete com.apple.screencapture killall SystemUIServer
LaunchAgent workflow
In the example listing of the ~/Screenshot directory shown earlier, all spaces were replaced with underscores. This is not supported by the Screenshot app, but we can use
LaunchAgents to monitor the ~/Screenshot directory and perform post-processing on the images and videos as they arrive.
Here is a LaunchAgent property list (plist) that shows how to replace the spaces with underscores and copy the path of the latest screenshot to the clipboard by calling a script whenever changes occur in the screenshot folder:
<?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>dk.thrysoee.screenshot_post_processing.plist</string>
<key>ProgramArguments</key>
<array>
<string>/Users/CHANGE_HERE/bin/screenshot-post-processing.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/CHANGE_HERE/Screenshot</string>
</array>
</dict>
</plist>
#!/bin/bash
while IFS= read -r -d '' oldpath; do
newpath=${oldpath// /_}
if [[ "$oldpath" != "$newpath" && ! -e "$newpath" ]]; then
mv -- "$oldpath" "$newpath"
printf '%s' "$newpath" | pbcopy
fi
done < <(
find "$HOME/Screenshot" -maxdepth 1 -type f -name 'screenshot *' -print0 | sort -z
)
screenshot-post-processing.sh
Download the shell script to, for example, ~/bin/, run chmod +x to make it executable.
Then download the plist and copy it to ~/Library/LaunchAgents. Run the following command to activate it:
for c in stop unload load start; do launchctl $c ~/Library/LaunchAgents/dk.thrysoee.screenshot_post_processing.plist; done