Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combine multiple files into one
Message
From
27/06/2008 15:40:17
 
General information
Forum:
Windows
Category:
Computing in general
Miscellaneous
Thread ID:
01327110
Message ID:
01327360
Views:
10
This message has been marked as a message which has helped to the initial question of the thread.
>>>Hi everybody,
>>>
>>>Is it possible with some Windows commands to combine multiple files (.sql) into one big .sql file? Preferably with adding GO in between?
>>>
>>>UPDATE.
>>>
>>>Nobody helps me, so I had to help myself.
>>>
>>>http://www.lagmonster.org/docs/DOS7/z-copy.html
>>>
>>>UPDATE2. DOS doesn't seem to recognize USB device, so I would have to copy the folder to the c drive.
>>>
>>>UPDATE3. Using DOS command resulted in garbage, so I manually combined the files (~6) using Edit and copy and paste technique. I already updated test server, now I have to update production.
>>
>>"DOS" (actually CMD) window with COPY command using concatenation works fine for me (note that in the following examples, none of the REM comments should be included in the actual test files). It should also work fine with USB drives, as long as their file systems are properly mounted i.e. have been assigned drive letters:
>>
>>REM Test SQL file TestSQL.sql
>>blah
>>blah
>>woof
>>woof
>>
>>
>>REM Go.txt
>>REM Intermediate insertion of the word "go":
>>REM Note the leading and trailing CRLFs in case a preceding or following file doesn't have them
>>REM Extra CRLFs in scripts are usually ignored
>>
>>go
>>
>>
>>Now you can concatenate the files:
>>
>>COPY TestSQL.sql+Go.txt Output.sql
>>
>
>Didn't work yesterday correctly for me.
>
>I tried COPY Create_*.sql LongSQL.SQL and only the first file was copied correctly, the rest was garbage. I also was unable to switch to USB drive from DOS cd command.

Your COPY syntax won't work as you're expecting. You definitely need to use the "+" for concatenation e.g.
COPY File1+go.txt+File2+go.txt+File3... Output.txt
Also, you can't change the currently selected drive with the CD command, although you can change the current folder on that drive. You just issue X: to change the selected drive to drive X:.

You don't have to change your selected drive if you're willing to put paths in front of all your file names in the COPY command.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform