Troubleshooting “Unexpected argument” error when running defaults write

command linescriptterminal

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

Best Answer

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