AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

binary merge?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ezuk



Joined: 04 Jun 2005
Posts: 146

PostPosted: Wed Jan 21, 2009 6:14 pm    Post subject: binary merge? Reply with quote

Hi everyone,

I'm trying to merge a couple of binary files.

For now, I'm doing it using the COPY command (console), but it's an ugly hack, and I actually want to distribute this utility.

Any clever ideas of how to do it smoothly, without using the Run command?
Back to top
View user's profile Send private message
BoBoł
Guest





PostPosted: Wed Jan 21, 2009 7:19 pm    Post subject: Reply with quote

Just use the Run command with its Hide parameter.
Back to top
ezuk as guest
Guest





PostPosted: Thu Jan 22, 2009 8:13 am    Post subject: Reply with quote

BoBoł wrote:
Just use the Run command with its Hide parameter.


But I'm afraid it won't always work on every computer.

No reason for me to be?
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Thu Jan 22, 2009 8:56 am    Post subject: Reply with quote

How large are the binary files?
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Thu Jan 22, 2009 9:35 am    Post subject: Reply with quote

ezuk as guest wrote:
BoBoł wrote:
Just use the Run command with its Hide parameter.


But I'm afraid it won't always work on every computer.

No reason for me to be?

It will work on any computer that AHK will work on. Hide is a function of AHK.
Code:
#SingleInstance, force
binfile1 = "e:\any dir\WIN95.PIF"
binfile2 = "e:\any dir\WIN952.PIF"
mergedfile = "%A_Temp%\outfile.bin"

Run, %comspec% /c copy /y /b %binfile1% + %binfile2% %mergedfile%, , hide
ExitApp
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Thu Jan 22, 2009 9:36 am    Post subject: Reply with quote

Anonymous wrote:
It will work on any computer that AHK will work on. Hide is a function of AHK.


Hide parameter never worked for me in Windows 98 ..
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Thu Jan 22, 2009 11:18 am    Post subject: Reply with quote

SKAN wrote:
Anonymous wrote:
It will work on any computer that AHK will work on. Hide is a function of AHK.


Hide parameter never worked for me in Windows 98 ..

That is funny, I tested on a win98se box and it works just fine. (and if there is an OS limitation, I would expect to see it in the help file). Smile
Back to top
BoBoł
Guest





PostPosted: Thu Jan 22, 2009 12:21 pm    Post subject: Reply with quote

Quote:
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
means that to me (which I use to merge a sliced mpeg video stream):
Code:
COPY /B source  /B + source /B + ... destination


No idea why this should work out fine
Code:
COPY /B source + source + ... destination
Question
Back to top
Guest






PostPosted: Thu Jan 22, 2009 12:34 pm    Post subject: Reply with quote

BoBoł wrote:
Quote:
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
means that to me (which I use to merge a sliced mpeg video stream):
Code:
COPY /B source  /B + source /B + ... destination


No idea why this should work out fine
Code:
COPY /B source + source + ... destination
Question


MSDOS 6.22 help file wrote:
/A
Indicates an ASCII text file. When the /A switch precedes the list of
filenames on the command line, it applies to all files whose names
follow the /A switch, until COPY encounters a /B switch, in which case
the /B switch applies to the file whose name precedes the /B switch.

When the /A switch follows a filename, it applies to the file whose name
precedes the /A switch and to all files whose names follow the /A
switch, until COPY encounters a /B switch, in which case the /B switch
applies to the file whose name precedes the /B switch.

An ASCII text file can use an end-of-file character (CTRL+Z) to indicate
the end of the file. When combining files, COPY treats files as ASCII
text files by default.

/B
Indicates a binary file. When the /B switch precedes the list of
filenames on the command line, it applies to all files whose names
follow the /B switch, until COPY encounters an /A switch
, in which case
the /A switch applies to the file whose name precedes the /A switch.

When the /B switch follows a filename, it applies to the file whose name
precedes the /B switch and to all files whose names follow the /B
switch, until COPY encounters an /A switch, in which case the /A switch
applies to the file whose name precedes the /A switch.

The /B switch specifies that the command interpreter is to read the
number of bytes specified by the file size in the directory. The /B
switch is the default value for COPY unless COPY is combining files.
Back to top
BoBoł
Guest





PostPosted: Thu Jan 22, 2009 12:56 pm    Post subject: Reply with quote

Thanks. I didn't have that "prehistoric description" at hand, so this makes sense to me now. Cool
Back to top
degarb



Joined: 14 Feb 2007
Posts: 307

PostPosted: Tue Jan 27, 2009 6:47 pm    Post subject: Reply with quote

The only thing I see missing is destination needs to exist in my experience. I would take some file delete all out of it except a byte, save.

Or is there a switch to avoid the need to create the destination file before merging to it?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Tue Jan 27, 2009 6:52 pm    Post subject: Reply with quote

degarb wrote:
I would take some file delete all out of it except a byte, save.


Code:
FileAppend,,degarb.mp3 ; will create a zerobyte file

_________________
URLGet - Internet Explorer based Downloader
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Wed Jan 28, 2009 3:40 am    Post subject: Reply with quote

degarb wrote:
The only thing I see missing is destination needs to exist in my experience. I would take some file delete all out of it except a byte, save.

Or is there a switch to avoid the need to create the destination file before merging to it?


Read the cmd.exe help (cmd.exe /?).
Quote:
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

which means that the output file will be created if it does not exist, and the /y means that the output file will be overwritten if it does exist.

This creates (or overwrites) newfile.bin.
Code:
copy /b /y file1.bin + file2.bin newfile.bin
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group