Little DOS help with wildcards

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
First of all I am running this under XP or 2003 so I don't know if that changes much. I have a bat file that is sensitive to certain environment variables in the time and date and I want to find a way to check for that so I did something like this:

Code:
For /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do (set DATE=%%k.%%i.%%j)

IF ????.??.?? == %DATE% echo ALL GOOD

Problem is that won't work for whatever reason even though the date is returned in this fashion "YYYY.MM.DD" which is what I need as I am using it in a file name so this is perfect for me.

I do know that if I do this it will work fine:

Code:
For /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do (set DATE=%%k.%%i.%%j)

IF 2006.12.11 == %DATE% echo ALL GOOD

I thought that I could use a "?" to replace a single character and a "*" for multiple characters but that doesn't seem to work at all.
 

Will Rickards

Storage Is My Life
Joined
Jan 23, 2002
Messages
2,012
Location
Here
Website
willrickards.net
Can you tell me in plain English or pseudo code what you are trying to do?

I think you are trying to run that if statement for each iteration of the for statement. But I don't think that is what is happening. Your do ends on the first line I think.
 

MaxBurn

Storage Is My Life
Joined
Jan 20, 2004
Messages
3,245
Location
SC
Can you tell me in plain English or pseudo code what you are trying to do?

I think you are trying to run that if statement for each iteration of the for statement. But I don't think that is what is happening. Your do ends on the first line I think.

It does end on the first line, the FOR statement outputs this on most computers with default environment variables = 2006.12.11

Basically I am trying to check the form of that result to make sure it doesn't somehow come out with something funky like a / that I can't use in a file name. Also I like the order, it stacks the directory results in ABC123 order in list view nicely.

This is part of a backup bat file I have for our application at work, just trying to make it a little better with some error control.
 
Top