Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
Batch File, Variable in File name?
Name: knudsj01 Date: April 5, 2005 at 08:19:21 Pacific OS: Windows 2000 CPU/Ram: Pentium 3, 256mb Ram
Comment:
Hello,
I'm having a problem with a batch file. I am trying to use a variable in a filename so that when run the output will go to a time stamped log file.
Here's the type of command I'm trying to run: ant task-name > C:\logfile%TIME%.log
Your command likely hides TWO bugs. The first is that reported by the error message probably due to the "-" character in the task-name. I do not know the Ant command, but utilities derived from Unix hates the "-" symbol as it prefixes parameters on the command tail.
So stated %Time% may lead to an error as it contains invalid characters due to the specific county settings as ":" To analize this problem please type at prompt
Echo Time=%Time%
and report the result so I can suggest the correction needed.
0
Response Number 2
Name: knudsj01 Date: April 5, 2005 at 12:18:18 Pacific
Well, as I supposed the Time format is not suited to be part of a PahtName/FileName. To work around the problem a bit of processing is needed; the following statements tailor the %Time%
Set MyTime=%Time% Set MyTime=%Mytime:~0,8% Set MyTime=%MyTime::=-%
as they strip out the secs/100 and replace the ":" with "-".
So you have to log to C:\logfile%MyTime%.log
So stated the first question is still with no answer: is what I said about the Ant command correct? As the batch interpreter never went to parse the logfile's name.
Summary: I want to create a batch file which will automatically copy a file created on the current day by using the system date variable, i.e. "xcopy /d:%date%" However the default value of this variable is i...
Summary: HI dtech , Thanks for the concern .. i guess i should have explained the scenario a little more .. I have a batch file which has to read certain lines from a command line .. the batch file runs a co...
Summary: I'm creating a batch fall that runs sqlplus. I want the batch file to either dynamically create the sql to include a variable as one of the criteria in the sql file. Can I either create the file dynam...