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

LVL 1
PJan8724Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Assuming this date is the only line in the text file, simply use something like this (NT4 or later):

@echo off
set DateFile=C:\temp\test.txt
for /f "delims=" %%a in ('type "%DateFile%"') do set TempDate=%%a
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PJan8724Author Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 2000

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.