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

May 24, 2010
855
0
Northlake, Il
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.
 
May 24, 2010
855
0
Northlake, Il
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
Thread starter Title Forum Replies Date
M Declined Function to to verify file name validity... Suggestions 4
Joe Caverly Link in Help File to Blog Articles Suggestions 0
Joe Caverly Declined Use ADS file with TOAST Suggestions 1
vefatica File name completion at the beginning of the command line Suggestions 6
Joe Caverly Done @FILESIZE and NTFS File Stream Suggestions 1
Joe Caverly Determine if a file is on an SSD drive Suggestions 5
Joe Caverly Declined Debug without first saving to a file Suggestions 3
R Declined File Explorer enhancement request Suggestions 8
D Secondary shells should not search for - but reuse - the current configuration file. Suggestions 11
Joe Caverly Declined Update FFIND in Help File with example for ORing expressions to search for Suggestions 6
D Done Re-activate the [secondary] section in the ini-file Suggestions 0
x13 Done Typo in help file (including PDF) | v24.02.46 Suggestions 0
R Declined wish-list: add a command to copy a file to clipboard. Suggestions 17
M Done Parameter to ignore [Escape] for FFIND /T"XXX" in a file Suggestions 5
Joe Caverly Done File completion for LIBRARY commands Suggestions 1
vefatica Declined Enhance file name completion Suggestions 4
D Declined File Explorer Suggestions 2
R Declined Install option: Add File Explorer Run As Adminstrator option Suggestions 14
mfarah Done TCEDIT: show the full name (with drive and path) of the active file on the title bar. Suggestions 3
R User-created extended help (probably in a text file): DIRHISTORY /?x Suggestions 10
Joe Caverly Declined Help File "See Also" Suggestions 4
thorntonpg Done Goto folder in file explorer from the current directory in the tcc prompt Suggestions 7
rconn add support for batch file projects Suggestions 0
rconn Done map the registry as a file system Suggestions 0
rconn Declined Help file organization Suggestions 0
rconn Done extend tcc file format Suggestions 0
K_Meinhard File descriptions for Explorer etc. Suggestions 1
J Directory Aliases and file:// Suggestions 0
G Declined Add option to turn on file name case sensitivity Suggestions 6
Stefano Piccardi Declined enhance FOR and DO with hexadecimal @file reading Suggestions 0
Joe Caverly Declined NTFS File Streams and ZIP Suggestions 12
J Declined Suggestions for file size display Suggestions 0
S Done Automatic quoting of directory and file names Suggestions 0
S Declined Enhanced file comparisons Suggestions 0
S Declined File timestamp based dates in file date selection ranges Suggestions 0
C Done "extended" icon display in file-view Suggestions 0
S Done File matching enhancements Suggestions 1
S Done File exclusion ranges, additional orderng and reporting options Suggestions 0
S Declined Enhanced @FILE for COPY, DESCRIBE, MOVE, RENAME, SYNC, TOUCH /R Suggestions 0
J Declined Test batch file for TCCLE compatability Suggestions 0
B Declined Direct/shortcut access to the File Search finctionality Suggestions 2
Charles Dye Declined Help file request Suggestions 2
K_Meinhard Declined file tags (mp3, jpg" Suggestions 19
H Done Start TCMD.EXE with an alternate INI file Suggestions 4

Similar threads