Reputation: 11
I am just getting starting in AppleScript and am testing out an existing script to see if I can get it to run on my computer. The error I get is here:
Expected “,” or “]” but found unknown token.
and it highlights the ~ in my if statement:
path="/Library/Desktop Pictures/Wallpaper-Blue-3D-logolow-2846x1600.jpg"
if [ -d ~/Library/Desktop\ Pictures/ ]
then
echo "Desktop Pictures directory already exists"
else
mkdir ~/Library/Desktop\ Pictures/
fi
What am I missing? Thanks!!
Upvotes: 0
Views: 49
Reputation: 1878
To avoid giving full disk access to mkdir shell command, use better the System Events or the Finder:
try
-- if the folder doesn't exist, then getting the alias will throw an error
alias ("" & (path to library folder from user domain) & "Desktop Pictures")
on error
-- Desktop Pictures of library of home doesn't exist, so create it
tell application "System Events" -- or, tell to Finder
make new folder at folder "Library" of home folder with properties {name:"Desktop Pictures"}
end tell
end try
Upvotes: 1