Category: files

Concatenate files under Windows

Recently I found the need two concatenate two javascript files in a build script under Windows. Using Linux concatenating two different files is easy using the cat command. It turns out that using Windows it is also trivial.

copy /b script1.js+script2.js combined.js

That’s it, really easy. The /b operator is added to let copy handle the files as binary files, for safety reasons.

If the destination file already exists, copy will prompt to overwrite. This prompt can be set to Yes by default by adding the /y option.

copy /b /y script1.js+script2.js combined.js

When combining files from different folders, e.g. ..\script1.js+.\htdocs\script2.js make sure you are using backslashes and not forward slashes in the path.

Leave a Comment