Searching for directories that contain two files of any name, with specific extensions

Viewed 19

I found this post that does what I am looking to do but the original poster knew what files they were searching for.

Finding directories that contains given files?

How would I update this find command to search for and list any sub directories that contain two files of any name but have two specific file extensions?

find -type d -exec sh -c '[ -f "$0"/index.php ] && [ -f "$0"/style.css ]' '{}' \; -print

Specifically I am looking to search all the subfolders for directories that contain a *.RAR file AND a *.VMK file. When I replace the "index.php" and "style.css" with the specific filenames of a known folder, I get the proper result.

Now I just need some help in replacing those specific filenames with the wildcard and extension.

I've tried these two options and they do not work as hoped.

find -type f '[ -f "$0"/*.rar ] && [ -f "$0"/*.vmk ]' '{}' \

find -type f '[ -f "$0"/"*.rar" ] && [ -f "$0"/"*.vmk" ]' '{}' \

Thank you in advance for your assistance, as it is much appreciated! :)

Regards.

2 Answers

Ugh. I made a COPY & PASTE error in my original post and posted one of my failed code attempts.

However, when I apply your comments Armali to what I meant to post, it worked as desired.

Here is what I ended up with:

find -type d -exec sh -c '[ -f "$0"/*.rar ] && [ -f "$0"/*.mkv ]' '{}' \; -print

Thank you.

The two options you tried differ significantly from the original working command. If you just replace index.php and style.css therein with your desired *.rar and *.vmk (without ""), respectively, it will work as long as there aren't more *.rar or *.vmk files in a folder.

Related