Created
March 25, 2020 10:59
-
-
Save TooDumbForAName/a7cc05b1a14be1dc99d7ce943e42b2bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Common function | |
createpopulatedir () { | |
mkdir "$DIRECTORY" | |
printf "%s\n" "Copying contents from $PWD to $DIRECTORY." | |
cp -r . "$DIRECTORY" | |
printf "%s\n" "Copying complete!" | |
} | |
#Prompt user for target directory | |
printf "\033[97m%s\n" "Please enter the directory you wish to copy files to." | |
printf "\033[31m%s\n" "Warning! All pre-existing files in directory will be deleted!" | |
printf "\033[97m%s" "Directory: " | |
read DIRECTORY | |
if [ -d "$DIRECTORY" ]; then | |
printf "%s\n" "Directory exists, deleting!..." | |
rm -rf "$DIRECTORY" | |
printf "%s\n" "Recreating empty directory..." | |
createpopulatedir | |
elif [ ! -d "$DIRECTORY" ]; then | |
printf "%s\n" "Directory does not exist, creating..." | |
createpopulatedir | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment