0

In the terminal in macOS, I can execute this command manually and it does what I want:

cd ~/Library/Preferences
mv Adobe "Adobe.old.$(date +%c)"

I'd like to create a simple script for this, that I can run through Terminal shell. I've tried creating a file with the following contents but it isn't working for me:

mv "~/Library/Preferences/Adobe" "~/Library/Preferences/Adobe.old.$(date +%c)"

I get the following output:

<name>@<machinename> desktop % sh adobecleanup.txt
mv: rename ~/Library/Preferences/Adobe to ~/Library/Preferences/Adobe.old.Mon Jan 18 16:44:15 2021: No such file or directory

1 Answer 1

3

You are enclosing the user home directory path preface ~/ in quotes.

Look at what you have done that works:

cd ~/Library/Preferences
mv Adobe "Adobe.old.$(date +%c)"

And look at the command that does not work:

mv "~/Library/Preferences/Adobe" "~/Library/Preferences/Adobe.old.$(date +%c)"

The key difference is in the case that works, the path is prefaced by ~/ and is unquoted. And in the command you are using that doesn’t work, the path is prefaced by "~/ and it is clearly quoted. When you do that the system is literally looking for ~/ as a literal path; not user home directory expanded path.

To get it to work either unquote the whole thing like this:

mv ~/Library/Preferences/Adobe ~/Library/Preferences/Adobe.old.$(date +%c)

Or just don’t include the prefacing path in the quoted path like this:

mv ~/"Library/Preferences/Adobe" ~/"Library/Preferences/Adobe.old.$(date +%c)"
1
  • beautiful.. thanks for the help! Jan 18, 2021 at 23:33

You must log in to answer this question.

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