views:

157

answers:

2

I have a folder C:\Scripts. In that folder I have 2 sub folders, Procedures and another Views. In the Procedures folder I have 2 files

proc1.sql
proc2.sql

in the Views table I have 2 files

view1.sql
view2.sql

I am trying to combine these files into one .sql file with the following batch file

Copy Procedures\*.sql proc.sql
Copy Views\*.sql view.sql
Copy proc.sql + view.sql Build.sql

The above is not working. When I run the Build.bat I don't see the Build.sql file. What am I missing?

+2  A: 

Dont use the copy command use the type command.

eg.

type Procedures\*.sql >> proc.sql
type Views\*.sql >> view.sql
type proc.sql >> Build.sql
type view.sql >> Build.sql

That should work exactly

RC1140
Make sure you use the >> to append data to the output file , use the > if you want to overwrite the data in the output file
RC1140
A: 
for %d in (view procedures) do for %f in (%d\*.sql) do type %f >> build.sql

I can't let a batch file question go by without a reference to my old friend the for command :-)

remember to user %% if in side a batch file

Preet Sangha