You need to watch out for a few things:
- Don't put spaces around the '=' in variable assignments
- When you have paths that could have spaces in them, surround them in double-quotes every time you use them
- Use 'fi' to end your if blocks
Here's a cleaner and (hopefully) working version of the the beginning of your code. The single
-d test can replace the looping you were doing.
Code:
path="C:\Document QC\"
targetDirectory="Input-Delete"
outputDirectory="$targetDirectory - Archive"
# Create the directory if it doesn't exist yet
if [ ! -d "$path$outputDirectory" ]; then
mkdir "$path$outputDirectory"
fi
# Don't know what this does...
forfiles -P "$path$targetDirectory" -S -M *.* -D -30 -C "cmd /C mv @FILE $path$outputDirectory"
I don't know what your last statement is trying to do. Are you trying to move a certain set of files from "$path$targetDirectory" to "$path$outputDirectory"? If you only want to move some of the files based on some test, you should probably use
find (check out the very long man page on it), specifically with
-exec.
If you'll explain that last bit, I could help you out with it.