Hi there,
I'd like to check that when the user enters a variable.. that it is a .txt file..
I've done something like this.. but no success right now..
:FileBegin
SET /p variable=[Enter the log file you need report(s) on] (e.g YYYYMMDD.txt) :
cscript /nologo c:\DATES.vbs %variable%
vb CODE is as follows:(Set objArgs = WScript.Arguments
strDate = objArgs(0)
s = Split(strDate,".")
yr = Mid(s(0),1,3)
mth = Mid(s(0),5,2)
dy = Mid(s(0),7,2)
If IsDate(yr&"/"&mth&"/"&dy) <> 0 Then
WScript.Echo "Valid date"
Else
WScript.Echo "Invalid date"
End If)
if %variable% NEQ %variable%.txt ECHO Enter a valid date with .txt extension
if %variable% NEQ %variable%.txt goto FileBegin
I want to check if the variable entered has an extension of .txt. i'm sure this is quite simple but Im not sure how to do it! I want to check the date first.. to see if that's valid.. then check to see if it's a .txt file..
I could always add it to the vbs code, what do you think?
Ps your answers have been great so far, thanks alot