Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

for f in *.txt
do
  echo -e -n '\n' >> "$f"
done
share
1  
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
add comment

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)

textFile.WriteLine()
textFile.Close()
Next
share
add comment

This site is currently not accepting new answers.

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