Gorba916
asked on
Merging text files together with batch commands?
I would like to be able to merge the contents of all text files in a root folder and its children folders into one output text file. Is this possible with batch commands (I'm using winxp), or is there a free app that can accomplish this? Either or is fine. Much obliged.
If you know the children folders and files its easy.
Example
copy /a \a.txt + /a \folder1\b.txt + /a \folderb\c.txt output.txt /a
Wildcards can be used.
If you don't know the children folders then some of the other gurus here can supply the answer.
Example
copy /a \a.txt + /a \folder1\b.txt + /a \folderb\c.txt output.txt /a
Wildcards can be used.
If you don't know the children folders then some of the other gurus here can supply the answer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks leew! I decided I wanted to try this on a series of XML files.
And your slightly modified command:
Echo.>SingleFile.txt
FOR /f "tokens=*" %%a in ('dir /b *.xml') do copy /a SingleFile.txt+%%a SingleFile.xml
Unfortunately only the last file on the list becomes SingleFile.xml... they aren't combining. Any ideas?
And your slightly modified command:
Echo.>SingleFile.txt
FOR /f "tokens=*" %%a in ('dir /b *.xml') do copy /a SingleFile.txt+%%a SingleFile.xml
Unfortunately only the last file on the list becomes SingleFile.xml... they aren't combining. Any ideas?
ASKER
Thanks GuruGary! It worked... with some modifications of course...
@echo off
setlocal
set RootFolder=D:\CFusionMX\ww wroot\Game MusicJukeb ox\
set OutputFile=D:\CFusionMX\ww wroot\Game MusicJukeb ox\Output. xml
for /f "delims=" %%a in ('dir "%RootFolder%*.xml" /b /s /a') do type "%%a" >>%OutputFile%
worked!
@echo off
setlocal
set RootFolder=D:\CFusionMX\ww
set OutputFile=D:\CFusionMX\ww
for /f "delims=" %%a in ('dir "%RootFolder%*.xml" /b /s /a') do type "%%a" >>%OutputFile%
worked!
For example:
Echo.>SingleFile.txt
FOR /f "tokens=*" %%a in ('dir /b *.txt') do copy /a SingleFile.txt+%%a SingleFile.txt