|Ok I'm going to start with holla's script and move on from there.|
On Holla's script the file and directory names were to be input as arguments, so it needed to be started from the command line with "script.cmd filename.exe directoryname".
Holla used for /f, which loops over a body of text, the text can either be a txt file or the output of a command, to get the total free space in bytes from the free space listed by the dir command. For more info on the for loop goto the command line and type in "for /?".
There is a trick that can be used on arguments and for loop variables, also explained in "for /?". The variables can become attributes of the file/directory data by using modifiers. These modifers are in the format of %~z1 or %%~pa. There are a few different modifiers, the one of interest here is "z". The z modifier is the file size in bytes.
As the data is in bytes and there are few avenues to obtain the data in megabytes or gigabytes we have to deal with quite large numbers. In windows 1gb = 1024mb, 1mb = 1024kb and 1kb = 1024bytes.
In 32bit windows signed 32bit numbers are used, these range from −2,147,483,648 to +2,147,483,647. Since we are only interested in positive numbers this essentially halves. 2,147,483,647 is the highest most things on the command line(windows nt based) will deal with including "if x mod x" where mod is gtr, lss, equ, geq or leq, see "if /?" for more info. If larger numbers are used 2,147,483,647 will be substituted in it's place.
Holla used "if x leq x...." to test if enough space was present. The largest file this can actually work on is 2,147,483,647/1024/1024/1024 or about 1.99gb. Anything larger will give a false positive if the free space is larger than 2gb and the file is larger still. As demonstrated by:
if 2147483648 leq 2147483647 echo something went wrong!
Now with all that out of the way onto your script.
"quotes" - the way you are using quotes is not suggested and would cause problems with some commands, start for one. If the file name contains a space or ampersand it is best to surround the whole path in double quotes not just the offending parts. For example "c:\documents and settings\usr1\desktop". Even if the path doesn't contain a space the quotes generally won't cause any trouble. Technically quotes are illegal characters in path names, most programs still work but some will call you on it.
You could definitely get some of the xcopy commands down using for loops but this post is getting pretty long so I'll leave that for now.......
As for the limitations I've been working on work-arounds but haven't got to the stage of comparisons yet, I've had some success with division, multiplication and addition. If you want I can post the division batch that can divide very large numbers by 1 to 9999999. That way you could test in megabytes instead...........