Batch Input From Txt File

November 16, 2010 at 07:50:42
Specs: Windows XP
I'm try to write a Batch that with will look on my hard drive and find a file with the date in it. and open that file and copy the text out of that file and set it as a variable that I can then use change.com to replace some text in my xml.

heres my code:

@echo off
REM gets the date
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set year=%%c
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set month=%%a
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set day=%%b

set Des=type c:\Txt\meta\pp-%month%-%day%.txt

for /f "tokens=* delims= " %%a in ('dir/b *.xml') do (
move /y "%%a" #
change # "***DES***" "%Des%"
echo.
move /y # "%%a"
)
echo.


when I run this i get the file name as the variable not the text from the file.


thanks


See More: Batch Input From Txt File

Report •

#1
November 17, 2010 at 03:26:29
No point in guessing at the date layout.

The odds are about the same as a single number in roulette. A couple dozen to one.


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
November 18, 2010 at 09:10:56
set Des=type c:\Txt\meta\pp-%month%-%day%.txt
when I run this i get the file name as the variable not the text from the file.

Yep. This is Command Prompt, not Bash.

Depending on what you want from the file, you might get away with:

set /p Des= < c:\Txt\meta\pp-%month%-%day%.txt

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question