# Linux – Recursively zip all files in a directory into individual zip files… but in a separate directory

command linelinuxunixzip

Similar questions have been asked, but I couldn't find exactly what I'm looking for. Basically, I have a large directory with subdirectories and many files, and I want to go into each directory and subdirectory recursively, and zip each file individually. I found this solution, but it's not quite what I want:

find . -type f -execdir zip '{}.zip' '{}' \;


Source

This outputs the zip files into the directory they came from. However, I want the zip files in a completely separate directory, but with the same directory structure, with only the resulting zip files. Can anyone help with this?

find . -type f -exec zip -D '../zipdir/{}.zip' '{}' \;

find . -type d -exec mkdir -p '../zipdir/{}' \;