I have this code to check the validity of a path: :: This checks if the drive and/or path does not exist ECHO Any junk text > JUNK1.TXT COPY JUNK1.TXT %Image_To_Path%JUNK2.TXT > NUL DEL JUNK1.TXT > NUL IF NOT EXIST %Image_To_Path%JUNK2.TXT GOTO ERRMSG22 DEL %Image_To_Path%JUNK2.TXT > NUL
This seems like a lot of code, and I still get (possibly confusing) screen messages from the COPY command when the path is invalid (It says something about "path\JUNK2.TXT".).
IF EXIST "%Image_To_Path%" ECHO It's there.
I tried that! That works in the Command Prompt in Windows XP, though I could not find where this feature was documented in the on-screen help ("IF /?"). I need to do this from a boot floppy running MS-DOS 7.10. In my testing in real DOS it "usually" behaved like the following:
IF NOT EXIST "%Image_To_Path%" ECHO It's there. IF EXIST "%Image_To_Path%" ECHO It's NOT there.By "usually" I mean the results depended on what the path looked like (ie. Did it include a drive letter, a path, both, end in backslash?). I thought a directory was a special type of file, and so it should work, but no luck this way!
In DOS i believe you can use nul to check the existence of a directory.
if exist s:\ome\path\nul echo echo s:\ome\path exists and is a directory
Thanks, I tested every kind of path I could think of and got the expected results in MS-DOS. I haven't tested in PC DOS yet, but I expect it should be OK too.
| « Need a batch file to impo... | vb script » |