Computing.Net > Forums > Programming > Wildcards in if statement

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Wildcards in if statement

Reply to Message Icon

Name: DragonL
Date: June 30, 2004 at 09:24:25 Pacific
OS: WinXP
CPU/Ram: NA
Comment:

I am using WinXP. I have a batch file that runs on every startup but I would like it to run only on a certain day of the week. I am trying to use if statements to check the date, but the %date% variable looks like Wed 06/30/04. Is there any way to use a wildcard like:

if "%date%"=="Thu*" do stuff

If anyone knows another way that would be helpful also. :)

-DragonL



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: July 1, 2004 at 00:55:17 Pacific
Reply:

You need to use the substring format of environment variables, so referring to your post

If "%Date:~0,3%"=="Thu"

where the general format is %Var:~m,n% with m being the starting positio of substring and n its length.

Type Set /? to get the full tutorial.


0

Response Number 2
Name: DragonL
Date: July 2, 2004 at 10:15:16 Pacific
Reply:

Thanks for the help :)

-DragonL


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Wildcards in if statement

Multiple commands in if statement www.computing.net/answers/programming/multiple-commands-in-if-statement/18063.html

BASH `echo $?` in if statement www.computing.net/answers/programming/bash-echo-in-if-statement/2271.html

Autorun If Statement www.computing.net/answers/programming/autorun-if-statement/13492.html