Okay, here is my issue,
I have around 1000 .zip files, give or take.
Each zip file has 1 file inside of it.
I want to delete the contents of each zip file while keeping the original zip file.
Yes I know I can open each zip file and delete the contents while keeping the original zip file but empty, one at a time,
but that would take forever!!
Does anyone know of a program that will let be delete all the files inside all the zip files at once ?
I want to keep the zip files the way they are named but just delete what is inside of them all.
I tried to see if there was a way to do it in bulk within winzip but could not find a way.
Also checked winrar and 7zip, but don;t see an option for what I want to do.
Total Commander maybe ??
Yeah, I know, I always come up with some crazy Q's no one seems to be able to answer....
+ Reply to Thread
Results 1 to 18 of 18
On a Windows system I would use PKZIP in a batch file like
for %%h in (*.zip) do pkzip -d %%h *.*
But surely when you delete the contents of a zip file you effectively delete the archive file. Or to put it another way, you can not have an empty archive.
I just tried it.
7-zip (free, open source) has the ability too:
One zip file:
7z d filename.zip *.*
for %%h in (*.zip) do 7z d %%h *.*
for %%h in (*.zip) do 7z d %%h thumbs.db
Ok. I only tried it manually within WinRar. Once the content was deleted, the .zip vanished from the folder.
Well I am sure the OP has a good reason for doing this but, unless, again, I am mistaken, an empty archive is going to use the minimum allocated disk space set by the file-system which could somewhat defeat the purpose.
Yes, after 7-zip deleted all the files the remaining ZIP archive was 22 bytes. But it occupied a 4 KB cluster on the drive it was on, of course.
Okay, thanks everyone!!
I have 7zip, always have, but it is not associated with zip files, I usually only use 7zip with 7zip files.
So exactly how do I run it with a command line ?
Do I need to run it in the same folder with the zip files ?
It has a section in the help file on running command lines and I am going to read it now, but a step by step for dummies would be great
So I have the command line/window open,
I have all the zip files in a folder in the root of C:
Last edited by Noahtuck; 29th Oct 2013 at 14:54.
If I learnt my previous lesson from jagabo correctly, you create a batch file with the command line inside it. Put the batch file somewhere you can find it and darg 'n drop your folder containing the .zip files on to it.
Okay, I have done stuff like that before, where you drag a folder or files into it and it does what it needs to do.
But it has been so looong I don't have a clue.
Man, you would think they would just include something in the menu to highlight and delete all the contents of all zip files.
Last edited by Noahtuck; 29th Oct 2013 at 15:09.
Okay, never mind.
I got it!!
I made the text file with the command line you guys posted and renamed it .bat
Deleted all the contents of the zip files so I still have all the zip files with their original names but they are now empty and take up 1.6mb instead of the 1gb they previously did.
Noahtuck I am in need of the same thing as you would you care to share your .bat file? I tried making one (I have never done it before) it did not work. I have a bunch of zips I would like to empty and keep the file name of the zip so I can add to them later.
for %%h in (*.zip) do "c:\program files\7-zip\7z.exe" d "%%h" *.*
Thank you for your help.
I changed the name of the BAT file to .TXT made the edit to C:\Program Files (x86)\7-Zip\7z.exe
Changed the extension back to .bat and when i drag and drop the folder windows asks to run, I hit yes and the command window opens like it is going to do something and disappears. the zips are not empty.
ok I had to drop one zip file on the bat file not the folder!
Works like a charm thank you so so much!
I tested on Win7. Behavior might be different in XP. If I remember correctly, the default folder when running BAT files in XP isn't the folder the BAT file is in but rather C:\Windows\System32. So the BAT file has to be modified for XP.
By the way, you don't have to rename the BAT file to edit it with Notepad. If you enter *.bat or *.* in the filename field the dialog will show you the BAT file. Or navigate to the folder the BAT file is in and start typing the name of the file -- you'll see the name pop up. Or put a shortcut to Notepad.exe in your SendTo folder. Then when you right click on any file you can select Send To -> Notepad.exe.
Last edited by jagabo; 24th Oct 2014 at 19:13.
jagabo, Thank you so much for reassuring that there still is some good left in people. You saved me approximately 200 hours of work that I did not have to lose.
Call me stupid, but what is the purpose of having a bunch of empty files?
Or if you for whatever reason really needed to do this, couldn't you just as easily create a batch file that saves the directory list, deletes all the (zip) files in the folder, and then creates empty zip files using the names from the list (whether directly, or by creating zero byte text files and renaming the extension)? It might be quicker.