3

Trying to change the default screenshot directory to a specific folder in my google drive, but when I try the following command

defaults write com.apple.screencapture location ‘~/Users/tommy\Google Drive\Sync\iMac\iMac Screenshots’

I get this error

2014-11-10 21:49:43.644 defaults[2184:76708] Unexpected argument DriveSynciMaciMac; leaving defaults unchanged.

and I don't know what I'm doing wrong.

enter image description here

2
  • I think it's trying to tell you that you can't use the Google Drive folder for that. Does it work outside of the folder? If so, will making a script to copy it elsewhere work?
    – Spotlight
    Nov 11, 2014 at 3:29
  • No I know it's a syntax issue, I just don't know how to fix it.
    – Tom
    Nov 11, 2014 at 3:44

3 Answers 3

3

In addition the quotes and slashes, it looks like you are trying to give an absolute path, so remove the tilde:

defaults write com.apple.screencapture location '/Users/tommy/Google Drive/Sync/iMac/iMac Screenshots/'

Don't forget to run killall SystemUIServer or logout afterwards

3

There are backs lashes (\) in your path that should probably be forward slashes (/). You also use curly quotes ( and ), which are weird at best. Try using straight quotes ('), although in that case straight double quotes (") should do as well:

defaults write com.apple.screencapture location '/Users/tommy/Google Drive/Sync/iMac/iMac Screenshots'
0

TL;DR;

# Make and/or Ensure The File Path Exists.
mkdir -vp "$HOME/Google Drive/Sync/iMac/iMac Screenshots"

# Update Your Screenshot Save Path
defaults write com.apple.screencapture location "$HOME/Google Drive/Sync/iMac/iMac Screenshots"

# Restart System UI.
killall SystemUIServer

# Check That The Setting Was Updated
defaults read com.apple.screencapture location

# Take a screenshot to add to your new location
Screenshot Your Screen or All Screens

CTRL+SHIFT+3

Note: Saves a Screenshot for every single screen connected to your computer. 3 screens == 3 saved images.

Screenshot By Click & Drag Selection

CTRL+SHIFT+4

Screenshot Window Selection

CTRL+SHIFT+4 the press SPACEBAR and drag your mouse over what window you want to screenshot, Then (Left) Click.

Custom Screenshot/Screen Recording Session

CTRL+SHIFT+5 Take screenshots or screen recordings on Mac

Details:

Ok, so here's my more verbose explanation:

You can also do this by replacing the ~ (tilde) with the $HOME

defaults write com.apple.screencapture location "$HOME/Google Drive/Sync/iMac/iMac Screenshots"

# Restart System UI.  Needed for the system to recognize the screenshot location change.
killall SystemUIServer

You can check the set value by running

defaults read com.apple.screencapture location

If you get

####-##-## ##:##:##.### defaults[####:######] 
The domain/default pair of (com.apple.screencapture, location) does not exist

Then the value has not been set...

Otherwise you should get a value back like this where tommy is your whoami

/Users/tommy/Google Drive/Sync/iMac/iMac Screenshots

IMPORTANT

If the file path does not exist your screenshots will default to saving to your ~/Desktop...

In Terminal try to cd to the directory to ensure it exists and/or that you typed it correctly:

cd "$HOME/Google Drive/Sync/iMac/iMac Screenshots"

If you don't get an error you are good to go.

If you cannot cd into that directory but you want to create it or make sure it is made then run this:

mkdir -vp "$HOME/Google Drive/Sync/iMac/iMac Screenshots"
man mkdir
# -v
#   Be verbose when creating directories, listing them as they are created.

# -p 
#   Create intermediate directories as required.  
#   If this option is not specified, 
#   the full path prefix of each operand must already exist. 
#   On the other hand, with this option specified, 
#   no error will be reported if a directory given as an operand already exists.
#   Intermediate directories are created with permission bits of “rwxrwxrwx” (0777)
#   as modified by the current umask, plus write and search permission for the owner.

This should fix any potential issues, by creating the file path that you expect/set.

Notes:

Single Appostrophe's. ' treat the values as literal characters.

Double Quote's: " evaluates the string before hand.

Backslashes: \ are used as escape characters & are not required for this example as the path is already in quotes. So there no need to escape the spaces.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .