Dan
Dan

Reputation: 31

Zip multiple folders and files depending on filesize in Linux/Ubuntu

I have a directory "mapnik" with hundreds of sub-directories, each containing more than 10000 files. I would like to zip "mapnik" recursively, preserving the folder-structure but only adding files greater than 103 Byte to the archive.

How can I accomplish this? I tried using find and pipes, but with the wrong syntax and the huge number of files, "trial and error" is not the best way to get it done ;)

Thanks for your help guys!

Upvotes: 2

Views: 671

Answers (2)

Dan
Dan

Reputation: 31

Delan's suggestion produced some kind of zip-error whith files of the same name. But it got me on the right track. This is what worked for me:

cd mapnik
find . -size +103c -print | zip archive.zip -@

Upvotes: 1

Delan Azabani
Delan Azabani

Reputation: 81384

How about

find -size +103c -print0 | xargs -0 zip -r outname.zip

Upvotes: 2

Related Questions