Category filter
Script to change screenshot settings on Mac
macOS, like every other OS, has a default way of dealing with screenshots. These default methods may not always align with the requirement of an organization or an employee’s work.
For example, Macs save their screenshots in PNG format by default, but the organization’s task management software may support only JPG files. Similarly, screenshots get saved to the Desktop by default, while the organization may prefer having screenshots saved in a dedicated folder as a measure to heighten security.
Changing the default screenshot configurations on each device individually to solve these issues isn’t feasible. This is where Hexnode UEM’s Execute Custom Script action comes in handy. IT admins can execute the scripts given below to modify the default screenshot configurations of devices in bulk and remotely.
Scripting Language – Bash
File extension – .sh
Script to change the default format of screenshots
1 2 3 4 |
LOGGED_IN_USER=`stat -f%Su /dev/console` su $LOGGED_IN_USER -c 'defaults write com.apple.screencapture type "format"'; killall SystemUIServer |
Macs save their screenshots as PNG files by default. Execute this script to change the default format of screenshots. Replace “format” with the required format.
For example,
1 2 3 4 |
LOGGED_IN_USER=`stat -f%Su /dev/console` su $LOGGED_IN_USER -c 'defaults write com.apple.screencapture type JPG'; killall SystemUIServer |
Once this script is executed, the screenshots further captured will be saved as a JPG file. Similarly, the default screenshot format can be changed to PDF, PSD, TIFF or others.
Script to change the default location of screenshots
1 2 3 4 |
LOGGED_IN_USER=`stat -f%Su /dev/console` su $LOGGED_IN_USER -c 'defaults write com.apple.screencapture location ~/"location"'; killall SystemUIServer |
By default, screenshots get sent to the Desktop. Replace “location” with the location of your choice and execute this script to change the default location of screenshots. It can be saved to Downloads, Documents, Photos or any dedicated folder of your choice.
For example, execute the script given below to change the default location of screenshots to the Downloads folder:
1 2 3 4 |
LOGGED_IN_USER=`stat -f%Su /dev/console` su $LOGGED_IN_USER -c 'defaults write com.apple.screencapture location ~/Downloads'; killall SystemUIServer |
Script to change the default naming of screenshots
By default, screenshots are saved with the name ‘Screenshot [date] at [time].png.’
Script to change the default prefix
Execute the following script to change the “Screenshot” prefix to anything of your choice. Special characters and numbers are supported too.
1 2 3 4 |
LOGGED_IN_USER=`stat -f%Su /dev/console` su $LOGGED_IN_USER -c 'defaults write com.apple.screencapture name "name of your choice"'; killall SystemUIServer |
Replace “name of your choice” with the required prefix.
For example,
1 2 3 4 |
LOGGED_IN_USER=`stat -f%Su /dev/console` su $LOGGED_IN_USER -c 'defaults write com.apple.screencapture name ACME'; killall SystemUIServer |
Once this script is executed, the screenshots will be saved as ‘ACME [date] at [time].png’
Script to remove date and time from name
Execute the following script to remove the date and time from the screenshot’s name.
1 2 3 4 |
LOGGED_IN_USER=`stat -f%Su /dev/console` su $LOGGED_IN_USER -c 'defaults write com.apple.screencapture include-date 0'; killall SystemUIServer |
Once this script is executed along with the previous one, the screenshots will be saved as ‘ACME.png’.