You can use this loop in bash:
for i in */; do zip -r "${i%/}.zip" "$i"; done
i is the name of the loop variable. */ means every subdirectory of the current directory, and will include a trailing slash in those names. Make sure you cd to the right place before executing this. "$i" simply names that directory, including trailing slash. The quotation marks ensure that whitespace in the directory name won't cause trouble. ${i%/} is like $i but with the trailing slash removed, so you can use that to construct the name of the zip file.
If you want to see how this works, include an echo before the zip and you will see the commands printed instead of executed.
Parallel execution
To run them in parallel you can use &:
for i in */; do zip -0 -r "${i%/}.zip" "$i" & done; wait
We use wait to tell the shell to wait for all background tasks to finish before exiting.
Beware that if you have too many folders in your current directory, then you may overwhelm your computer as this code does not limit the number of parallel tasks.
*/names every direct subdirectory, not every descendant directory. So you'll only get zips for the uppermost level, just the way you want them. The version withechoin it would have demonstrated that aspect. Zipping every nested directory into its own file would in fact be more work, and probably best solved usingfind -type damong other tricks. – MvG Mar 19 '13 at 21:53for i in *; do zip -r "${i%}.zip" "$i"; done– Nux Sep 08 '16 at 08:09zipbinary is you might get different behavior. In order to also create zip files for top level directories (i.e. children of current directory) starting with a dot, you could useshopt -s dotglobto make glob patterns match hidden files as well. – MvG Aug 13 '18 at 17:24for i in */; do (cd "$i"; zip -r "../${i%/}.zip" .); done– chris Sep 06 '18 at 12:51