Simple:
DEL C:\Rubbish\GetRidOfIt.txtNo problem above, the DEL command will know what to do. However, lets assume the directory "C:\Rubbish" is actually called:
C:\My Garbage(note the space? yes, you do!) - so you enter
DEL C:\My Garbage\GetRidOfIt.txtOne of the improvements in Win95 and above is that you can enter multiple file specs on the command-line for DEL (and a lot of other commands too). The above command will be interpreted by Windows as
DEL C:\My DEL Garbage\GetRidOfIt.txt
Probably not what you want... The second command (DEL Garbage\....) could be in any directory where your script is running, how would you know? It would use the "current directory" to find out which file you meant.
Lets suppose you wanted to remove some files in the program-files directory:
DEL C:\Program Files\My Program\*.*Windows would try to
DEL C:\Program DEL Files\My DEL Program\*.*
So....
Inside batch scripts and on command-lines, ALWAYS enclose everything in "quotes", this tells Windows: No, I am not entering multiple arguments here, please treat this as a single file-spec
DEL "C:\Program Files\My Program\*.*" DEL "C:\My Garbage\GetRidOfIt.txt"
Why do I tell you this?
Because our WatchDirectory program and future WatchFTP program starts your batch files with a lot of %VARIABLES% (see here), and they are not surrounded with quotes!
DEL "%WD_FILE%"
Just "quote" everything in your batch script
No comments:
Post a Comment