Creating a variable in Dos -

Microsoft Windows xp professional w/serv...
May 27, 2010 at 21:07:33
Specs: Windows XP
I have a dos batch file which appends data to the end of a record (see below). The data is repeated numerous times. Is it possible to create a variable instead and then reference that variable. This would eliminate the number of times it needs to be changed.

I tried the SET command (i.e. SET date1=05272010), but then when I replace all my 05272010 in the code with date1, it displays the value date1 instead of 05272010. Additionally, I tried using the %date1% in places where 05272010 appeared but still no luck.

Any help is greatly appreciated.

p.s. Our office is planning on converting to Windows 7 in the near future. Would you happen to know if batch files will still work in Windows 7?
::This batch file does the following:
:: 1) appends a date to the end of a file. Done multiple times.
:: 2) appends all files together
:: 3) deletes files

del test_combined_data.txt

@echo off & setlocal EnableDelayedExpansion

for /F "tokens=* delims=" %%j in (c:\users\mom\test05272010.txt) do (echo %%j 05272010 >> testnew_05272010.txt)
for /F "tokens=* delims=" %%j in (c:\users\mom\test05282010.txt) do (echo %%j 05282010 >> testnew_05282010.txt)
for /F "tokens=* delims=" %%j in (c:\users\mom\test05292010.txt) do (echo %%j 05292010 >> testnew_05292010.txt)

copy testnew_05272010.txt + testnew_05282010.txt + testnew_05292010.txt test_combined_data.txt

del testnew_05272010.txt
del testnew_05282010.txt
del testnew_05292010.txt

:: End_Of_Batch

See More: Creating a variable in Dos -

Report •

May 28, 2010 at 04:18:07
ciru, back in my Commodore 64 days you could, assume you still can, but dunno how. You'll likely get more and more knowledgeable responses in the programming forum @:
Ed in Texas.

Report •

May 28, 2010 at 05:18:52
Thanks Ed. I will post there.

Report •

May 28, 2010 at 13:56:36
Batch scripts running under Windows XP are perfectly compatible with Windows 7.

Aboit your question what you want to achieve is absolutely possible and quite easy, but your batch is cumbersome and so confused (with useless statements) that I do not understand the core of the issue.

Report •
Related Solutions

Ask Question