# 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](https://www.hexnode.com/mobile-device-management/help/how-to-run-scripts-on-mac-using-hexnode-mdm/) 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

 Disclaimer: 
The sample scripts provided below are adapted from third-party open-source sites.

 

Script to change the default format of screenshots
--------------------------------------------------

Script to change screenshot format

LOGGED\_IN\_USER=`stat -f%Su /dev/console` su $LOGGED\_IN\_USER -c 'defaults write com.apple.screencapture type "format"'; killall SystemUIServer

   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,

Script to change screenshot format to JPG

LOGGED\_IN\_USER=`stat -f%Su /dev/console` su $LOGGED\_IN\_USER -c 'defaults write com.apple.screencapture type JPG'; killall SystemUIServer

   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
----------------------------------------------------

Script to change default screenshot location

LOGGED\_IN\_USER=`stat -f%Su /dev/console` su $LOGGED\_IN\_USER -c 'defaults write com.apple.screencapture location ~/"location"'; killall SystemUIServer

   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:

Script to change default screenshot location to Downloads

LOGGED\_IN\_USER=`stat -f%Su /dev/console` su $LOGGED\_IN\_USER -c 'defaults write com.apple.screencapture location ~/Downloads'; killall SystemUIServer

   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.

Script to change default screenshot name prefix

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

   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,

Script to change default screenshot name prefix

LOGGED\_IN\_USER=`stat -f%Su /dev/console` su $LOGGED\_IN\_USER -c 'defaults write com.apple.screencapture name ACME'; killall SystemUIServer

   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.

Script to remove date and time from screenshot name

LOGGED\_IN\_USER=`stat -f%Su /dev/console` su $LOGGED\_IN\_USER -c 'defaults write com.apple.screencapture include-date 0'; killall SystemUIServer

   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’.

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.