Find & Delete directories in .zip files

zip

Question 1 : In many .zip archive files I would like to delete directories anwsering to a name pattern.
In a "normal" directory I used :

find . -type d -name "pattern" -mtime +30| xargs rm -r

Is it possible to find/delete these directories without having to unzip the .zip files?

If I do have to unzip I have to zip them again after deleting those files, which I would like to avoid.

I saw a few topics which advised to mount .zip files to use shell commands. Could it work for me too ? (I'm quite new to the Unix World).

Question 2 :
i did like Mark said and put everything in a loop. It works fine but without asking for anything i get in the terminal for each deleted file/folder a line :
"deleting: blabla.txt".
How is it possible to get these lines in a log file ? Just adding >> ${logFile} after the command line would be enough ?

Best Answer

As @MarkPlotnick pointed out, you can use glob patterns. From man zip:

zip -d foo foo/tom/junk foo/harry/\* \*.o

will remove the entry foo/tom/junk, all of the files that start with foo/harry/, and all of the files that end with .o (in any path).

Related Question