0
votes

Im very new to VBScript (this is my first time ever using it). So far I've copied and altered my way into getting as far as I am.

I have an APK file that is too big for my needs. So what I've been doing is manually changing it to a zip and then deleting a couple images from it then renaming it back to an APK. Im trying to automate that with a VBScript. So far I have

Set oShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = WORKSPACE & "\temp\" & app & "\build\" & PLATFORMSUBFOLDER & "\dist\" & app & "\bin"
oShell.CurrentDirectory = sFolder 

'Make the Apk a Zip.
fso.MoveFile apkfile, zipApk

This is all working and I can see in Windows Explorer that the APK changes to a zip like I want it to. So Im wondering if there is any quick ways to just go in and delete a couple files without extracting the whole thing?

If not is there an easy way to extract the files and parse them at the same time?

Ive looked here Extract files from ZIP file with VBScript but cant seem to get it working. I keep getting error "Object required: 'objShell.Names(...)'" Any hints to why this is happening?

1
may be install 7zip and use it in command line mode that vbs can execute in a shell? Some description.PatricK

1 Answers

1
votes

Use the MoveHere method to move an item out of the zip file:

zipfile = "C:\path\to\your.zip"
fname   = "some.file"
dst     = "C:\some\folder"

Set app = CreateObject("Shell.Application")
For Each f In app.NameSpace(zipfile).Items
  If f.Name = fname Then
    app.Namespace(dst).MoveHere(f)
  End If
Next

Then delete the files from the dst folder:

Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile fso.BuildPath(dst, fname), True