How to write a variable into a text file using batch script

February 3, 2015 at 22:16:22
Specs: Windows 7
I have list of files in a particular folder such as filename_yyyymmdd, I should break this filename into two parts such that one variable holds filename and the other variable holds yyyymmdd.
Then i should write this variables value into another text file.

I have written the batch script as follows:

set FOLDER_PATH=D:\folder\Data\data
pushd %FOLDER_PATH%
for /F "tokens=1* delims=_" %%a in ('dir /B *.txt') do set fname=%%a & set fdate=%%b
break>D:\folder\Data\data\file.txt
echo %fanme%>>file.txt
popd


See More: How to write a variable into a text file using batch script

Report •

#1
February 4, 2015 at 04:18:13
Explain better what you want to achieve: do you want to create one file holding the filenames or two files, one storing the names and the other the related dates?

Software is founded on *absolute* precision, no tolerance is allowed opposite to engineering practices.


Report •
Related Solutions


Ask Question