Batch script help

aerosmith's Avatar, Join Date: Jan 2008
Newbie Member
I really do not know where to go to find a solution for this question of mine, so i decided to ask in this programming forum as you guys would be better with computer stuff.
I want to know a way to merge a picture and a zip folder together into one file, such that if i change the extension to ".jpg", the file opens up showing the picture (as if it was a picture file) and when i change the extension to ".zip", it opens up as a zip folder with the contents all intact (as if it was just a zip file).

i managed to do it successfully with a jpeg picture and a rar file using a batch code:


Code:
/b copy (pic file) + (rar file) (file i want)

and all was successful
but when i did it with a zip file, as a picture, it opens up nicely but as a zip, an error says zip file is corrupted

and so i suspect that it is the different binary structure of zip and rar files that caused this

can anyone tell me a solution please, all help appreciated even though this is a programming forum, and i am asking in the wrong forum, please do help help me as a kind favor.
0
Bhullarz's Avatar
Skilled contributor
I tried the following, the result was unsuccessful :
Code:
copy 1.rar + 2. jpg 3.rar
Code:
copy 1.jpg + 2.rar 3.rar
Code:
copy 1.rar + 2.jpg 3.jpg
Code:
copy 1.jpg + 2.rar 3.jpg
0
aerosmith's Avatar, Join Date: Jan 2008
Newbie Member
thats because you did not copy in binary mode
have a jpeg picture named 1.jpg ready
have a rar file of anything name 2.rar ready
create a batch file with this command
have all 3 files on the desktop

Code:
copy /b 1.jpg+2.rar 3.jpg
run script
it will create 3.jpg which has combined size of 1.jpg and 2.rar.
this 3.jpg can be opened to reveal picture of 1.jpg, and when renamed to 3.rar, it can be opened to show files which 2.rar contains.

i have some theories, it could be that windows picture and fax viewer reads the 3.jpg file in an order such that when it reads the header data of a picture data, it will display the picture, when win rar is used to open 3.rar, it will read the initial data containing the picture file but since it does not understands it, it skips pass that chunk of data and when it reads the header data of a rar file (something it was made to do) it opens it up as a rar file. this is because binary copy command literally copies the data of the second file after the first without mixing the data up. another interesting thing i noticed is that when this "hybrid" zip is opened with win rar, everything is fine, but when opened with windows native zip handler, "compressed (zipped) folder" it errors that file is corrupted.

can anyone tell me if my theory is right since i am not an expert in the area of how a program executes a file.

thanks again, all your help is appreciated.
0
Mikey's Avatar, Join Date: Jan 2008
Newbie Member
I slung together a painfully simple program to do this.



Download the attachment and open it in WinRar

Dont forget to read the readme

Last edited by shabbir; 28Jan2008 at 22:53.. Reason: Non-related image deletedq
0
aerosmith's Avatar, Join Date: Jan 2008
Newbie Member
thanks, but i dun see the program attachment
and what does your program do?
and btw, it has to be bat or anything that can be created easily with native win xp without programming softwares, cos the terminals i am using have no internet and removable storage devices are not allowed.
thanks again
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
aerosmith, the attachment is removed because it contained images not related to the posts.
0
stussyking's Avatar, Join Date: Sep 2008
Newbie Member
anybody with a better solution ?
any web based script solution ? php ? ruby ?