Jump to content
Sign in to follow this  
MartinB

Combine Several files into one File

Recommended Posts

MartinB

Hi,

I what to copy several files into one single file. In MS-DOS I would use Copy file*.dat = new.dat

Eg.

3 files starting with paybacs*.dat combine into one file call Opay.dat.

I have try FileCopy not all 3 thress are in the new file created.

Can someone help.

thanks :">

Share this post


Link to post
Share on other sites
trids

Why not just automate the DOS command? No need to re-invent the wheel :P

Share this post


Link to post
Share on other sites
MartinB

Why not just automate the DOS command? No need to re-invent the wheel :P

How or what do you mean? Some of this is new to me so any help would be greatly received.

Share this post


Link to post
Share on other sites
trids

Sorry :P .. something like this untested code:

;au3 script code
    $sPath = "C:\Some Place\"
    Run ('@COMSPEC /c COPY "' & $sPath & 'paybacs*.dat" Opay.dat', "", @SW_HIDE)

edit: debugged the code

Edited by trids

Share this post


Link to post
Share on other sites
big_daddy

What if the files being copied are not in the same place as the destination file?

This should allow for that:

;Don't forget the trailing \
$Path1 = "C:\Path to files being copied\"
$Path2 = "C:\Path to file being copied to\"
RunWait(@Comspec & " /c copy " & $Path1 & "paybacs*.dat" & " " & $Path2 & "Opay.dat", @TempDir, @SW_HIDE)

edit: forgot a space after copy

Edited by big_daddy

Share this post


Link to post
Share on other sites
MartinB

Sorry :P .. something like this untested code:

;au3 script code
    $sPath = "C:\Some Place\"
    Run ('@COMSPEC /c COPY "' & $sPath & 'paybacs*.dat" Opay.dat', "", @SW_HIDE)

edit: debugged the code

I have tried you example and get an errror unable to find files.

i have attached the au3 script code, so you can see what i am trying to do.

BACSConvert2.au3

Share this post


Link to post
Share on other sites
trids

Around line 85, try replacing your..

Run ('@COMSPEC /X COPY "' & $sPath1 & '$sPath2', "", @SW_HIDE)
with this..
Run ('@COMSPEC /X COPY "' & $sPath1 & '" "' & $sPath2 & '"', "", @SW_HIDE)

Share this post


Link to post
Share on other sites
MartinB

Around line 85, try replacing your..

Run ('@COMSPEC /X COPY "' & $sPath1 & '$sPath2', "", @SW_HIDE)
with this..
Run ('@COMSPEC /X COPY "' & $sPath1 & '" "' & $sPath2 & '"', "", @SW_HIDE)

i have replaced the line and the error is on this line and states:

Error: Unable to execute the external program.

The system cannot find the file specified.

Share this post


Link to post
Share on other sites
trids

Not sure what "/X" does .. i usually use "/C" after @COMSPEC.

Try copying the line you want to execute to the clipboard and then paste the results to a DOS session and run it there..

;Run ('@COMSPEC /C COPY "' & $sPath1 & '" "' & $sPath2 & '"', "", @SW_HIDE)
$sDOS  = @COMSPEC & ' /C COPY "' & $sPath1 & '" "' & $sPath2 & '"'
ClipPut($sDOS)
Run ($sDOS, "", @SW_HIDE)

edit: eureka (i think?)

Edited by trids

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×