3

Been banging my head against the wall few hours now....

trying to recursively zip subfolders, but only the files in them. I've been trying to modify this script:

for i in */*/; do zip -j -r "${i%/}.zip" "$i" ; done

This is almost perfect, but zipped files still has the actual subfolder with files in it. Expected result would only to have the files in the zip file not the subfolder containing the files.

Any help appreciated. Thanks

tbone99
  • 31

1 Answers1

1

There is something better already in the manual of zip, that makes use of find

man zip

Modifying it a bit it becomes

find . -type f -exec zip source {} \;

You can use it after a cd to the folder you want, or you can substitute the . with it, like

find ~/Downloads/ -type f -exec zip source {} \;
dadexix86
  • 6,616