Thursday, 26 September 2013

Simple File Concatenation


Concatenating SQL scripts (or any other file for that matter) should be simple, and it is.

Two methods:

1) This method uses the DOS copy command to concatenate all files in the target directory with the .sql extension to another file called concatenated.txt.

copy /a *.sql concatenated.txt

(Tip: Make sure the destination file has an extension different that the files being combined, otherwise it will itself get added to the concatenation at the end of the process).

2) for %f in (*.sql) do type “%f” >> concatenated.txt

This variant will pipe all of the files with a .sql extension into the destination files called concatenated.txt.


No comments: