How to validate a string is a valid path

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
scavenger
Posts: 8
Joined: 23 May 2015 13:51
Contact:

How to validate a string is a valid path

#1 Post by scavenger » 28 Jan 2020 21:59

Challenge:
- the string path is likely to be on a remote computer (I'm testing backup path returned for some remote SQL servers)
- you cannot try to create the path locally (after all it may be a drive letter not available locally)
- use the minimum lines of code (I can foresee a for loop with : and \ as delimiters)

That's a question... for dummies like me. On Linux it'd be very easy with a simple regex validation.
Have any of you guys done this before?
Would a simple pipe findstr /R do the trick?

thanks

scavenger
Posts: 8
Joined: 23 May 2015 13:51
Contact:

Re: How to validate a string is a valid path

#2 Post by scavenger » 28 Jan 2020 22:27

don't bother and archive this.

Code: Select all

echo %REMOTE_PATH% | findstr /I /R "[c-z]:\\[a-z]"
and test ERRORLEVEL, done.

Post Reply