Batch script help

Discussion in 'Windows' started by aerosmith, Jan 1, 2008.

  1. aerosmith

    aerosmith New Member

    Joined:
    Jan 1, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. Bhullarz

    Bhullarz New Member

    Joined:
    Nov 15, 2006
    Messages:
    253
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    System Manager
    Home Page:
    http://www.tutors161.com
    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
    
     
  3. aerosmith

    aerosmith New Member

    Joined:
    Jan 1, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. Mikey

    Mikey New Member

    Joined:
    Jan 28, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I slung together a painfully simple program to do this.

    :pleased:

    Download the attachment and open it in WinRar

    Dont forget to read the readme
     
    Last edited by a moderator: Jan 28, 2008
  5. aerosmith

    aerosmith New Member

    Joined:
    Jan 1, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    aerosmith, the attachment is removed because it contained images not related to the posts.
     
  7. stussyking

    stussyking New Member

    Joined:
    Sep 15, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    anybody with a better solution ?
    any web based script solution ? php ? ruby ?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice