I’m writing a shell script to backup the contents of the current directory to a timestamped subdirectory, ./STATES/$DATE. Obviously I do not want to STATES directory itself to be re-copied each time I backup the folder, so I need to somehow exclude it from the copy.
Here’s an untested shell script showing how I’d approach this on *nix:
ID="$(date +%Y%b%d%H%M%S)"
COMMITABLE="$(ls | egrep --invert-match ^STATES\$)"
STATE_PATH="$(pwd)/STATES/$ID"
mkdir --parents "$STATE_PATH"
cp $COMMITABLE "$STATE_PATH"
ln -s "$STATE_PATH" PARENT
How could I achieve this in a batch file?
xcopy‘s/exclude:$FILEoption can be used to specify a file containing filenames to be ignored. A friend of mine converted the script to batch like this: