The first step is to launch Terminal.
It is in the Applications folder in the utilities folder.
Type or paste the following line into a Terminal window and hit the Return key to execute the command:
defaults write com.apple.screencapture type jpg;killall SystemUIServer
Type or paste the following line into a Terminal window and hit the Return key to execute the command:
defaults write com.apple.screencapture type gif;killall SystemUIServer
Type or paste the following line into a Terminal window and hit the Return key to execute the command:
defaults write com.apple.screencapture type PDF;killall SystemUIServer
Type or paste the following line into a Terminal window and hit the Return key to execute the command:
defaults write com.apple.screencapture type png;killall SystemUIServer
Type or paste the following line into a Terminal window and hit the Return key to execute the command:
defaults write com.apple.screencapture type tiff;killall SystemUIServer
How to change where screenshots are saved on Mac
Step 1: Make sure to  create the folder you want the screenshot to go to.
  
Step 2: Search for Terminal in Spotlight Search in the top-right menu bar.
  
Step 3: Open Terminal and type the following command: defaults write com.apple.screencapture location ~/Documents/Screenshots
  
Step 4: To apply the changes, enter the following command: killall SystemUIServer
    
  
 If you entered the commands successfully, your screenshots will now save to a Screenshots folder within your Documents.
    Note that you can type any directory that you wish to save screenshots to, as it doesn’t have to be ~/Documents/Screenshots if you would prefer something else. For example it could be Documents, or Downloads.
  
To revert back to saving screenshots to your desktop,  enter the following command:
    defaults write com.apple.screencapture location ~/Desktop 
    followed by:
    killall SystemUIServer