Go4Expert (http://www.go4expert.com/)
-   Windows (http://www.go4expert.com/forums/windows-forum/)
-   -   Batch script help (http://www.go4expert.com/forums/batch-script-help-t8058/)

aerosmith 1Jan2008 14:03

Batch script help
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:


/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.

Bhullarz 3Jan2008 00:45

Re: Batch script help
I tried the following, the result was unsuccessful :

copy 1.rar + 2. jpg 3.rar

copy 1.jpg + 2.rar 3.rar

copy 1.rar + 2.jpg 3.jpg

copy 1.jpg + 2.rar 3.jpg

aerosmith 4Jan2008 17:00

Re: Batch script help
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


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.

Mikey 28Jan2008 21:30

Re: Batch script help
I slung together a painfully simple program to do this.


Download the attachment and open it in WinRar

Dont forget to read the readme

aerosmith 9Feb2008 09:48

Re: Batch script help
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

shabbir 9Feb2008 10:26

Re: Batch script help
aerosmith, the attachment is removed because it contained images not related to the posts.

stussyking 15Sep2008 19:27

Re: Batch script help
anybody with a better solution ?
any web based script solution ? php ? ruby ?

All times are GMT +5.5. The time now is 00:32.