Link to home
Start Free TrialLog in
Avatar of PJan8724
PJan8724

asked on

Input Data from a text file into a batch file variable.

Hello all,

I have a small problem, I have a batch file that I wrote (see code below) that I need to input data from a text file into a variable within the batch file.  The data the the text file will contain is simply today's date in the following format (Mon 04/03/2005) which will be read into the batch file and be used the following day.  In short what I'm trying to accomplish is a date misus one calculation without writing some big log script to do the calculations.  I wrote a VB app that does exactly what I need it to do, but the securtiy nazi's around here told me that I can't use exe's or VB scripts on the servers...

Code Sample:

@echo off

rem setting the current date

Rem TempDate <--  This is the variable that I want to get from another file.

set yy=%date:~12,2%
set mm=%date:~4,2%
set dd=%date:~7,2%

set name=ex%yy%%mm%%dd%.log

rem creating file name using current date and
rem copying to another location using the same name.
rem change copy command to reflect desired locations.

copy c:\temp\ex%yy%%mm%%dd%.log c:\temp2\ex%yy%%mm%%dd%.log

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PJan8724
PJan8724

ASKER

Hey oBda,

Thanks for the help, I actually came up with a similar solution yesterday after doing some more research but yours is a little better then mine so I'm going to go with.  However I did want to say thanks for all you help.

Pete J.