top of page

Windows Command to Combine Multiple Text Files and Insert the File Names at the Beginning of the Con


This is a demonstration of a a simple script you can run in Windows command prompt to combine multiple text files and add the file names of each to where each source file begins. See my how to video posted to YouTube:

1. In the folder with your source files, press CTRL + SHIFT and right click. Then chose 'Open command window here'.

2. In command prompt, type:

findstr "^" *.txt

and then make reference to a new folder where you will write a new text file merging the source files together.

>C:\Process\output2.txt

Press return to run the script. So the full script is just:

findstr "^" *.txt >C:\Process\output2.txt

3. The new text file that is generated will combine the full contents of the source files, and add in the file names at the beginning of each file's content.

If the original text file had line breaks, the file name will be added at the beginning of each line. If not, it will just be added at the beginning of the file's contents.

An example of where this command would be useful is a case where you want to add the text from emails to a new column in a spreadsheet to which you've exported the metadata for those emails.


Recent Posts

See All
backup mode for robocopy

When using robocopy command in Windows to copy files, note that if you are an admin you can use the /B switch to copy files from...

 
 

Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page