Solved bat file to write folder name and contents of specific file

June 15, 2012 at 08:27:18
Specs: Windows XP
I need a bat file to traverse a directory and its subfolders for a specific file name which will be the same in each directory and write the contents of that file along with the folder name to a text file. I have this to write the contents, but because the name is the same it overwrites the contents. I need to write out folder name, and then contents of that file called 'THISFILE' to one text file called 'testfiles.txt'

@echo off
FOR /R %%a IN (.) DO COPY "THISFILE" "testfiles.txt"


See More: bat file to write folder name and contents of specific file

Report •

#1
June 15, 2012 at 21:14:20
✔ Best Answer
maybe give this a fling (value for 'test.txt' needs to be arranged...):

@echo off >op & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('dir /b /s test.txt') do (
>>op echo %%a
copy op+"%%a" op
)
:end
not tested...


Report •
Related Solutions


Ask Question