By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done Verify validity of file name and/or path...

While I've got code I've been using for a long time ("%@ExecStr" a batch file), it would be really nice if in addition to "Exist", "IsFile", and "IsDir", there was an "IsPath" (for instance), which would be true if the given path is valid. In the case of the rightmost component of the path, just verify that the name is acceptable ("St*r", for instance, would fail the test) and for the rest of the path (everything preceding the rightmost component and separated from the rightmost component by a back slash) that the drive (if specified) and all of the leftmost components of the path are valid, exist, and are directories.

Just for reference, the existing batch file echos:
3 For a valid device (CON:, LPT1:, COM2, NUL:, etc.)
2 For an existing directory
1 For an existing file
0 For a valid name that does not exist
-1 For a high-order component that is not a valid path (not all components exist and are directories.
-2 For an invalid (syntax) path/name
-999 For something that exists but is not a file, a directory, or a device
(Should really never happen)

This, of course, wraps all of the tests into one value.
A path minus the filename is a directory. How about:
if isdir %@path[...]
Thank you Vince, I was already doing that (I guess I really didn't make that clear because I was describing what it did, not how it did it, which in truth I didn't even remember the details of because it was written years ago and I didn't really spend any time looking at the code - it was just a very old "building block" that I use pretty much without thinking about it.) But I'll note that that's only a relatively small part of the complete task.

Similar threads