I’ve got thousands of .zip
files in subdirectories with a few different errant images in them we’ll call crap.*
. But they’re different cases in the filenames. The files could have different extensions and some additional character in front of or behind the crap
, such as 123crap567.jpg
or -crap-.gif
.
I’m trying to write a bash script for Linux to scan through the directories, find the zip’s with the CrAp.PNG
, and delete that file from within the zip. Below is my code I’ve got so far, but it’s not working.
I believe I’m scanning through and finding the correct zip files, and identifying the exact name of the “crap files”. But I’m getting:
zip error: Invalid command arguments (specify just one action)
What am I doing wrong?
for i in *.zip; do
[ -f "$i" ] || break
f=$(zipinfo "$i" | grep -i -ho "S*crapS*")
if [[ $f ]]; then
zipinfo "$i" | grep -i -ho "S*crapS*" | xargs zip -d '*/$i'
fi
done