I want to check to see if a couple of directories exist and if not create them before running rest of the script
I’m using if-then-else statements but that is not working for me. I find I have to run the script 3 times: 1st-time it creates the first directory, 2nd – it creates the second directory and then 3rd – time it runs the rest of the script. After the directories have been created the script runs fine. I just don’t want it to have to run it three times before it works as it should.
Thanks
#!/bin/sh
if r ! -d $ZZdesktop ]; then
mkdir -p $ZZdesktop
else
if ! -d $ZZdocuments ]; then
mkdir -p $ZZdocuments
else
rsync -ahv --progress --delete "/Users/$CUser/Desktop/" /Users/$CUser/Box Sync/$CUser/zz_backup/z_desktop/ 2>> /Users/Shared/${CUser}syncerror_desktop
fi
fi