22

Is there a Notepad++ plugin out there that automatically combines all currently opened files into a single file?

Update: Yes, I am very aware of copy and paste :) I'm working with lots of files, and I want a solution that makes this step in the process a little bit faster than several dozen copy and pastes.

I'm aware of utilities for combining files, but I want the convenience of combining specifically the files that are currently opened in my text editor.

If there isn't a plugin out there already, I'll write one myself; I was just wondering if it exists already to save me the time of developing one.

JR.
  • 5,840
  • 9
  • 31
  • 34
  • 1
    @delnan If you're combining 20 files at a time, that can get kind of tedious... – JR. Oct 19 '10 at 18:33
  • It's propably still faster than looking for a plugin, installing it, realizing it's not working, finding another one, running it, realizing it screwed up and fixing everything by hand :D Okay, serious: If there's an existing solution, great, but there propably isn't. –  Oct 19 '10 at 18:39
  • if you're on Windows you don't need NP++ - https://stackoverflow.com/questions/3418549/need-to-combine-lots-of-files-in-a-directory – CAD bloke Jun 09 '22 at 06:09

3 Answers3

20

I used the following command in DOS prompt to do the merge for me:

for %f in (*.txt) do type "%f" >> output.txt

It is fast and it works. Just ensure that all the files to be merge are in the same directory from where you execute this command.

tgarcia
  • 675
  • 9
  • 21
Hendrik
  • 201
  • 2
  • 2
15

http://www.scout-soft.com/combine/

Not my app, but this plug in lets you combine all open tabs into one file.

user3330447
  • 179
  • 1
  • 5
  • I've tried it today August 28, 2015 with the latest notepad++, it still works perfectly. Thanx a lot for sharing this resource. – Techno.Shaman Aug 27 '15 at 22:32
  • Wonderful. Note, since I use the Plugins Manager, I was not able to download the plugin from the author's site and save it in the Plugins folder. However, the Plugins Manager had no trouble finding the plugin and I was able to install it easily that way. – aparente001 Jul 28 '16 at 14:54
  • 1
    To use just open all the files you want to merge, and then do Plugins -> Combine -> Start. The merged text will get popped into a new file and your focus will automatically go to the new file, which you can then save and edit. Great solution. – aparente001 Jul 28 '16 at 14:56
  • Although oddly, I couldn't re-open the merged (saved) file with notepad++! I had to open it with notepad and copy and paste into a new file. So don't panic if that happens to you. – aparente001 Jul 28 '16 at 15:04
13

I installed the Python Script plugin and wrote a simple script:

console.show()
console.clear()
files = notepad.getFiles()
notepad.new()
newfile = notepad.getCurrentFilename()
for i in range(len(files) - 1):
    console.write("Copying text from %s\n" % files[i][0])
    notepad.activateFile(files[i][0])
    text = editor.getText()
    notepad.activateFile(newfile)
    editor.appendText(text)
    editor.appendText("\n")
console.write("Combine Files operation complete.")

It looks at all the files currently opened in Notepad++ and adds them to a new file. Does exactly what I need.

JR.
  • 5,840
  • 9
  • 31
  • 34
  • It looks like it doesn't work fine when there is a no saved file opened. When that happens, all files are combined in the last saved filed opened. Anyway, very useful. – jddsantaella Oct 26 '12 at 08:32
  • 1
    Just used this in 2020. Still works great. One edit I made to the script was len(files) - 1. to just len(files). With 3 files opened it only merged the first 2. Overall, exactly what I was looking for. – Tim Sanders Oct 28 '20 at 16:16