AutoHotkey Community

It is currently May 26th, 2012, 2:30 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: binary merge?
PostPosted: January 21st, 2009, 7:14 pm 
Offline

Joined: June 4th, 2005, 1:54 am
Posts: 146
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 8:19 pm 
Just use the Run command with its Hide parameter.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 9:13 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 9:56 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
How large are the binary files?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 10:35 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 10:36 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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 ..


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 12:18 pm 
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). :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 1:21 pm 
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
:?:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 1:34 pm 
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
:?:


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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 1:56 pm 
Thanks. I didn't have that "prehistoric description" at hand, so this makes sense to me now. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 7:47 pm 
Offline

Joined: February 14th, 2007, 8:01 pm
Posts: 308
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 7:52 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2009, 4:40 am 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: G. Sperotto, poserpro and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group