I need to find every folder with more than one PDF in a folder structure but hide the pesky hidden files such as
.HResource files that infiltrate our file system.
I only want to filter folders that have HiRes in the filename.
Ideally I want to run this at top level so it searches every folder with HiRes and spits out the folders with more than one PDF inside it.
The OS is RHEL 7 and this command can be run as user/root as required.
I have had a play with
find -type f -iname '*.pdf' -iname '*HiRes*' ! -iname '.*' -printf '%h\n' | sort | uniq -d
but have had very little luck so far as the hidden files keep showing and thus in a 11,000 folder system giving thousands of false positives. For example, given the following directory structure,
. |--Apples.HiRes1 | |--Gala.pdf | |--Granny Smith.pdf | |--McIntosh.pdf | |--Red Delicious.pdf |--Banana-HiRes2 | |--upper.pdf | |--subdir | | |--lower.pdf |--Cherry_HiRes3 | |--Bing.pdf | |--Blossom.jpg | |--.pesky | |--.hidden | |--.files | |--.HResource |--Dates (HiRes4) | |--Midsummer.Pdf | |--New Year’s Eve.PDF |--Employees | |--Fred.pdf | |--Ginger.pdf | |--New Hires | | |--Sam Malone.pdf | | |--Woody Boyd.pdf |--Gemstones | |--Rubies | | |--1.pdf | | |--2.pdf | |--Sapphires | | |--3.pdf | | |--4.pdf |--Tomato.HiRes | |--Bacon | |--Lettuce | | |--5.pdf | | |--6.pdf |--Zucchini.LoRes | |--Bread.pdf | |--Squash.pdf
the output should be
./Apples.HiRes1 ./Dates (HiRes4)
Cherry_HiRes3is excluded because it has only one PDF file in it.
Tomato.HiResare excluded because they have two PDF files under them, but not in them.
Zucchini.LoResis excluded (obviously) because its name has