Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an easy way to do this? I'm actually combining about 500 files using copy *.txt myoutputFile.txt. The problem is, that command inserts the new/next file at the current/end position of the file, where I need it to be inserted on a new line.

share|improve this question
for f in *.txt
  echo -e -n '\n' >> "$f"
share|improve this answer
just echo >> "$f" would work... but OP's use of 'copy' infers OP is on a windows box. Alas. You'd have to create a file containing a CR, then y'know... it's just painful to do it on a Windows box. Wait! There's Quickbasic scripts in MS Word! To the BatMobile!! (Ain't gonna do it!) Even using a Linux LiveCD would be faster. – lornix Jul 25 '13 at 2:58
on windows , one place they suggest "do more" | for %%a in (*.txt) do more %%a >>file.doc | . and not using a .txt extention on the output so a loop doesnt occur. This method for the merging puts them on seperate lines, so no need to add to each file. – Psycogeek Jul 25 '13 at 3:23

I decided to just make a quick VBScript:

Dim fso, folder, files
Dim strPath

Const ForAppending = 8

' Create a FileSystemObject  
Set fso = CreateObject("Scripting.FileSystemObject")

' Define folder we want to list files from
strPath = "C:\members"

Set folder = fso.GetFolder(strPath)
Set files = folder.Files

' Loop through each file  
For each item In files

set textFile = FSO.OpenTextFile(item, ForAppending)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .