Big Millz
Big Millz

Reputation: 93

Copying files containing text, and files within several specifically named subfolders

I have several folders like so:

I'm looking to grab all jpg files containing "fanart" as well as all jpg contents of each extrafanart folder, and copy these all to a single folder like so:

I've gotten this far:

find . -type f \( -iname "*.jpg" -iname "*fanart*" \) -exec cp '{}' fanart \;

But I can't figure out an efficient way to grab the contents of the extrafanart folders. Ideas?

Upvotes: 0

Views: 18

Answers (1)

Barmar
Barmar

Reputation: 781310

Use -o to specify different criteria. You can use the -path option to match files in a subdirectory

find . -type f \( -name '*fanart.jpg'* -o -path '*/extrafanart/*.jpg' \) -exec cp {} fanart \;

Upvotes: 1

Related Questions