Sublime Forum

Concatenate open files into one new file


I recently had 680 HTML files open in ST o_O I was impressed.

But I actually wanted one (additional) HTML file, with the contents from the other 680.

I tried really hard to find a way to automate it and in the end just used RSI ctrl+c ctrl+v.

Anyone know how to achieve this with ST4 or a plugin?



The easiest way to do that is a shell script, eg:

$ cat www/*.html > all_together.html


Nice, but on Windows and I think cmd is disabled for us : (



This could be achieved fairly easily with a plugin, in a technical sense. It’s easy to get the list of files that are open in a window, and it’s easy to grab the content from one and append it into another.

The trickier part comes in what happens if there are some files you DON’T want, and in what order it’s supposed to happen, if that matters. Also, what about buffers that are open and have content in them but are not saved to disk? For files that ARE on disk, what if they have unsaved changes? Save first, or try to grab the content from disk instead of using the current content?

1 Like


Great questions. It’s moot right now for me, after some hours dealing with this for 680 open files by hand (lol), I no longer need the facility; but; it would be good to have this capability. Albeit these questions you raise would need to be addressed.