1

I have a .apk file at path C:\BatchTest I want to do the following things using a batch file.

Rename the .apk file test.apk to test.zip

Open test.zip

Go to a folder abc inside test.zip and delete its contents.

Rename test.zip back to test.apk

Any suggestions how can this be done.

Sid
  • 45
  • 2
  • 9
  • Check my zipjs.bat here : http://stackoverflow.com/questions/28043589/ can remove content from a zip , but I'm a little bit busy at the moment.Later will post a solution for you without using any external tools. – npocmaka Apr 21 '15 at 09:15

2 Answers2

1

I advise you to use the command-line version of 7zip, using parameters you can adapt the zip, See here for examples. The renaming part can be done in a batch, i suppose that won't be a problem ?

I you master a scripting language like Ruby this can all be done in a script.

peter
  • 41,770
  • 5
  • 64
  • 108
  • Thanks for your reply @peter. I was however looking for a generic batch file which has all the commands. – Sid Apr 21 '15 at 09:16
  • That is what i propose in the first part, you can put these commands in a batch. – peter Apr 21 '15 at 09:17
  • 1
    There is no built-in handling of compressed files in batch. However, there are workarounds, as npocmaka wrote. I don't see an advantage using this kind of blackhack. I recommend: use 7-Zip. You can use the exe as "portable" if you don't want to install it. – MichaelS Apr 21 '15 at 09:35
  • @MichaelS: did i say there is build in handling ? I say to use 7zip command-line version – peter Apr 21 '15 at 09:50
  • You've misunderstood my comment. I'm shearing your oppinion and recommending to use 7zip, too. – MichaelS Apr 21 '15 at 09:54
1

Here it is without external tools:

@echo off

copy test.apk test.zip /Y
rmdir abc /s /q >nul 2>nul 

call zipjs.bat unZipItem -source %cd%\test.zip\abc -destination %cd%\abc -keep no -force no
rmdir abc /s /q >nul 2>nul

you'll need zipjs.bat in the same directory.Though you dont need to rename the file.Extension does not matter.

npocmaka
  • 55,367
  • 18
  • 148
  • 187