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.
Batch File Variables Troubles
Name: NBlock Date: October 8, 2003 at 07:33:32 Pacific OS: n/a CPU/Ram: n/a
Comment:
I've got a batch file in which I'm having to manipulate a few variables concerning dates. As the program executes, it parses the date into individiual variables such as month number (i.e. 09 for September, 10 for October, etc.). I need to know how to be able to subtract one month from that variable but still have it be two digits (i.e. 10 minus 1 be "09" rather than "9"). Currently, the leading zero on months 01-09 is lost when I make that subtraction.
Name: IVO Date: October 8, 2003 at 08:57:32 Pacific
Reply:
I assume you are running your batch under Windows NT/2K/XP (an NT-kernel based system) as you stated about string parsing and arithmetic, operations not usually performed under Windows 9X/ME.
If so, after subtraction you have to test
If "%Month:~1,1%"=="" Set Month=0%Month%
and you get the vanished 0.
This works only under the previously reported operating systems. I hope this helps
0
Response Number 2
Name: IVO Date: October 8, 2003 at 09:02:38 Pacific
Reply:
Obviously in my previous post substitute Month with your variable name!
0
Response Number 3
Name: NBlock Date: October 8, 2003 at 11:33:51 Pacific
Summary: I am confused on how to create and use batch file variables. I would like to have the user input information (if possible) and assign that information to a variable. If this is not possible I would st...
Summary: I am trying to figure out how to program variables in batch files. Any help on the following script would be helpful. Thanks!! :test net send * Hello set %A%=0 set %B%=%A%+1 If %B%= 50 GOTO 2 Else Got...
Summary: Hi. I hve written a batch file which connects to a series of computers, checks for the existence of a file then published the result, however I have a different section in the batch file for for each ...