问题
I have a thousand zip archives that all contain a file I want to remove. I can get 7Zip to remove them one file at a time from the command line:
7z d -r archive.zip *.pdf
but how would I apply that across all the files, which are themselves grouped in sub-directories?
回答1:
Try this:
for /r %v in (*.zip) do 7z d -r "%v" *.pdf
But no idea if it's working, just wrote out of my head :P
回答2:
FOR /F "tokens=*" %%G IN ('dir /b *.zip') DO 7z.exe d -r %%G *.pdf
This works almost in the same way as the accepted answer. Only the way how the files are gathered is different. Whereas the answer above uses for /r
to run through all directories and subdirectories, this one parses the output of the command dir /b *.zip
to get all the files relevant.
The 7zip command remains the same and only the parameters are changed.
Note: To run this outside of a batchfile replace %%G
with %G
回答3:
Sometimes simple things can solve the problems...
do the following to delete any file / all file from selected .zip files>
- Move the .zip files to a new folder
- Select all the files from which files to be deleted
- right click and select option "extract each archive to separate folder"
- all the zip files shall be converted to folder now.
- use and file search tool like SearchMyFiles and find required files, select and delete.
- convert the folders back to .zip
来源:https://stackoverflow.com/questions/22344587/how-to-delete-a-file-from-multiple-zip-archives-using-7-zip