Skip to main content
1 of 5
Nasser
  • 1k
  • 2
  • 10
  • 13

how to delete all pdf files in specific named folder in large tree?

I have large tree, with many pdf files in it. I want to delete the pdf files in this tree, but only those pdf files in sub folders named rules/

For example, I have this tree. Everything below 'source'

 source/ A/ rules/*.pdf etc/ B/ keep_this.pdf rules/*.pdf whatever/ C/ D/ rules/*.pdf something/ 

and so on. There are pdf files all over the place, but I only want to delete all the pdf files which are in folders called rules/ and no other place.else.

I think I need to use

 cd source find / -type d -name "rules" -print0 | xargs -0 <<<rm *.pdf?? now what?>>> 

But I am not sure what to do after getting list of all subfolders named rules/

Any help is appreciated.

On Linux mint.

Nasser
  • 1k
  • 2
  • 10
  • 13