I've got 50 to 60 files in a directory that I need to concatenate into a single file on a regular basis.
I thought about using notepad++ thinking there was probably a plug-in that would help but haven't been able to find one.
Any other thoughts?
I've got 50 to 60 files in a directory that I need to concatenate into a single file on a regular basis.
I thought about using notepad++ thinking there was probably a plug-in that would help but haven't been able to find one.
Any other thoughts?
Use the Windows 'copy' command.
C:\Users\dan>help copy
Copies one or more files to another location.
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]
source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
/D Allow the destination file to be created decrypted
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/N Uses short filename, if available, when copying a file with a
non-8dot3 name.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
/L If the source is a symbolic link, copy the link to the target
instead of the actual file the source link points to.
The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.
**To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).**
So in your case:
copy *.txt destination.txt
Will concatenate all *.txt files in alphabetical order into destination.txt
Thanks for asking, I learned something new!
Assuming these are text files (since you are using notepad++) and that you are on Windows, you could fashion a simple batch script to concatenate them together.
For example, in the directory with all the text files, execute the following:
for %f in (*.txt) do type "%f" >> combined.txt
This will merge all files matching *.txt into one file called combined.txt.
For more information:
you could use powershell script like this
$sb = new-object System.Text.StringBuilder
foreach ($file in Get-ChildItem -path 'C:\temp\xx\') {
$content = Get-Content -Path $file.fullname
$sb.Append($content)
}
Out-File -FilePath 'C:\temp\xx\c.txt' -InputObject $sb.toString()