I have a directory of 86 xml files with the same columns and formatting that I need to combine into one large xml file. I am very inexperienced with batch files, and my first attempt was to simply append one file text onto the next using...
FOR %%i IN (directory\*.001) DO type %%i >> directory\combo_file.001
Unfortunately, this creates a Parse error when i try to open it in excel. I would imagine that this is because many fields and tags are repeated. Does anyone know how I might be able to achieve this? I only need to open this file in excel, so I would be open to converting files to CSV, if that was an option.
Any help is much appreciated, thanks!
A very easy approach will be to do a simple copy:
copy *.xml new.xml
The new.xml file created will have all the xml files merged together. You can create a BAT file with the same command
Here's a quick batch command that combines all the xml files in the current directory into a single file CombineXML.bat. It wraps all the XML files with a new root node ("<root>").
In your case, however, you may not want to introduce this new layer to the XML. If all you're doing is viewing the XML in a single area (eg: in a web browser) then this works.
--CombineXML.bat--
@echo on
rem ==clean up==
erase %0.xml
rem ==add the root node==
echo ^<root^> > %0.txt
rem ==add all the xml files==
type *.xml >> %0.txt
rem ==close the root node==
echo ^<^/root^> >> %0.txt
rem ==rename to xml==
ren %0.txt %0.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With