I'm trying to figure out a way to recursively search a directory structure for files matching a specific string, and then displaying
multiple matches per line, with each directory's results on a new line... So, for example, searching for files matching *index*.jpg in the following directory structure:
toplevel\ (folder where script is run)
toplevel\subfolder1\some index file.jpg
toplevel\subfolder1\another index file.jpg
toplevel\subfolder2\more index file.jpg
toplevel\subfolder2\yet another index file.jpg
would result in a list that looks something like this:
toplevel\subfolder1\:
some index file.jpg TAB another index file.jpg
toplevel\subfolder2\:
more index file.jpg TAB yet another index file.jpg
The TAB can be a | or some other text string, doesn't have to be an actual TAB, but something I can easily regex or grep on the result file.
I've been trying to work something along the lines of:
Code:
find -maxdepth 2 -name Contact*index*jpg -execdir ls -C {} \; > output.txt
but it's listing everything in a single line so I'm not quite sure how to approach this. Even the command above would work if I could somehow append a custom string after the last result in each folder, though it wouldn't be as elegant as automatically breaking each directory's results onto its own line. Can someone offer some help?