Zip all subdirectories in a directory and ignore files

42 Views Asked by At

Im looking for a script that can zip all subdirectories of a directory, but ignore the files within said directory.

e.g.

/foo
/foo/bar
/foo/baz
/foo/barbaz.txt

Would become

/foo
/foo/bar.7z
/foo/baz.7z
/foo/barbas.txt

I've gotten as far as this but it zips every file as well which is totally unnecessary when most of the files in the parent directory are lightweight text or pdf files.

`for i in /foo/*; do f=$(basename -- "$i"); 7z a "/foo/$f.7z" "$i"; rm -Rf "$i"; done`
0

There are 0 best solutions below