I am creating a bash script that is suppose to copy all files in
~/Development/ to another computer on my network. I have enabled it to mount the computer if it is not there, but my real problem is creating folders.
I want to save the files in
/Volumes/Users/Public/InfiniteBackups/Development/, therefore I run some if statements to check if they exist.
#! /bin/bash echo "Starting Backup of Development Files" echo say "Starting Backup of Development Files" if [ -d "/Volumes/Users/Public/" ]; then # Control will enter here if $DIRECTORY exists. echo "Location is there..." echo # Start echo "Copying Files" echo if [ ! -d "/Volumes/Users/Public/InfiniteBackups/Development" ] ; then echo "/Volumes/Users/Public/InfiniteBackups/Development did not exist." say "Location did not exist, creating it." cd /Volumes/Users/Public/ if [ ! -d "/Volumes/Users/Public/InfiniteBackups"]; then say "InfiniteBackups did not exist, creating it…" mkdir InfiniteBackups fi if [! -d "/Volumes/Users/Public/InfiniteBackups/Development"]; then cd InfiniteBackups mkdir Development fi fi cp -v -rip ~/Desktop/ /Volumes/Users/Public/InfiniteBackups/Development echo "Files have finished transferring" say "Files have finished transferring" fi
It will say /Volumes/Users/Public/ exists, and it will say /Volumes/Users/Public/InfiniteBackups/Development does not exist. It then checks to see if /Volumes/Users/Public/InfiniteBackups/ exists, which it shouldn't. Then it is suppose to make the directory. However, it instead acts like the volume did exist even though it clearly doesn't.
Why doesn't it work. Thanks.