#/bin/bash # zip all non-7z and non-zip files with 7z in pwd and delete the original for f in ./*; do ext=${f##*.} if test "$ext" = zip; then continue; fi; if test "$ext" = 7z; then continue; fi; 7z a -sdel "$f.7z" "$f" done