Yaroslav Bulatov
Yaroslav Bulatov

Reputation: 57923

zip archive from a directory tree but only include files with extensions xx1,xx2,...?

What's a combination of commands on MacOS that'll start at the root of some directory tree and create a zip file archive of it, preserving directory structure, but only including files with extensions "ext1" and "ext2"?

Upvotes: 0

Views: 344

Answers (1)

llasram
llasram

Reputation: 4475

How about:

cd DIRECTORY/..
find DIRECTORY -type f '(' -name '*.ext1' -or -name '*.ext2' ')' | xargs zip OUTPUT

(First chdir to the parent of the desired directory so that the paths in the ZIP file will include that directory but no parents in its path names).

Upvotes: 1

Related Questions