none
Need help in VB script (in renaming or deleting a file inside the Zip file) - URGENT!!!! RRS feed

  • Question

  • Could someone please provide vbscript for renaming or deleting the file which is inside a ZIP file without extracting.Also it should not give any prompts while executing.

    Thanks,

    Anil.

    Monday, September 12, 2011 2:53 PM

Answers

  • Hi,

    AFAIK, there is no supported means to rename a file inside a zip file. (By supported, I mean using an API and not hacking the file directly.)

    Zip command-line tools usually support deleting files from a zip file. Two free possibilities are 7-Zip and Info-Zip.

    HTH,

    Bill

    Tuesday, September 13, 2011 2:47 PM
    Moderator

All replies

  • Could someone please provide vbscript for renaming or deleting the file which is inside a ZIP file without extracting.Also it should not give any prompts while executing.

    Thanks,

    Anil.

    You could do this:

    1. Use a VB Script to read the whole .zip file as a string into memory.
    2. Replace every instance of the old file name with the new file name. The length of the two names would have to be the same.
    3. Save the file.

    This method is based on one single try, using the XV32 binary editor. Whether it works for all .zip files and whether it maintains the integrity of the .zip file is anyone's guess (unless you are completely familiar with the internal structure of a .zip file).


    Monday, September 12, 2011 4:34 PM
  • Could someone please provide vbscript for renaming or deleting the file which is inside a ZIP file without extracting.Also it should not give any prompts while executing.

    Thanks,

    Anil.

    You could do this:

    1. Use a VB Script to read the whole .zip file as a string into memory.
    2. Replace every instance of the old file name with the new file name. The length of the two names would have to be the same.
    3. Save the file.

    This method is based on one single try, using the XV32 binary editor. Whether it works for all .zip files and whether it maintains the integrity of the .zip file is anyone's guess (unless you are completely familiar with the internal structure of a .zip file).



    This is a great solution.

    Have you tried it?

    I have a zip file open and I cange the name in a binary editor. I save it...plot thickens!

    I now double click zip file an "Donk!: "Compressed(zipped) Fo;der is invalid or corrupt".

    I suggest getting teh pkzip comamndline tools.  PK also has a net and com library, I believe, so automation from PowerShell and VBScript should be good.

     


    jv
    Monday, September 12, 2011 11:29 PM
  • Don't zip files have an imbedded crc of the payload that's calculated when the files are zipped, and then checked again when they're unzipped?


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Monday, September 12, 2011 11:40 PM
    Moderator
  • I still have one of the early PK-Zips, with a package size of 863KB (year 2001).  And I remember the days when anything prefixed with PK was cool.
    [string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
    Tuesday, September 13, 2011 10:01 AM
  • I still have one of the early PK-Zips, with a package size of 863KB (year 2001).  And I remember the days when anything prefixed with PK was cool.
    [string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"


    PK and WinZip are still the nly archive tools that do almost everything including gz,tar,arc,lhz, etc.

    7Zip and the PowerSHell ziplibrary are both good but only for Windows ZIP files.  They still will not unzip in the latest compression format.

     


    jv
    Tuesday, September 13, 2011 11:23 AM
  • Hi,

    AFAIK, there is no supported means to rename a file inside a zip file. (By supported, I mean using an API and not hacking the file directly.)

    Zip command-line tools usually support deleting files from a zip file. Two free possibilities are 7-Zip and Info-Zip.

    HTH,

    Bill

    Tuesday, September 13, 2011 2:47 PM
    Moderator