1
1
I'm trying to create a series of playlists on my MP3 player, running Rockbox, by finding a file matching a string, using find /cygdrive/g/MUSIC -type f -name "Search Criteria" | /cygdrive/g/PLAYLIST/Playlist Name.m3u8
.
When I search using $ find /cygdrive/g/Music -type f -name "*Theme*"
, my results are:
/cygdrive/g/Music/Movie Masterpieces/14 - 1900's Theme.ogg
/cygdrive/g/Music/Movie Masterpieces/02 - Deborah's Theme.ogg
/cygdrive/g/Music/Star Trek_ The Motion Picture [Disc 1]/01 - Ilia's Theme.ogg
However, I would like to be able to search for any folder and output the names of the files inside, for an output similar to:
/cygdrive/g/Music/Cult Themes/01 - The Avengers (1965).ogg
/cygdrive/g/Music/Cult Themes/02 - Man In A Suitcase (1968).ogg
/cygdrive/g/Music/Cult Themes/03 - The Saint (1962).ogg
I have access to both a Linux terminal, cygwin or Windows command prompt, and would be grateful for any solution, but if possible in one or two lines.
Edit: After receiving the a number of solutions, I've found the best solution was:
find /cygdrive/g/MUSIC -type d -iname "*theme*" -print -prune
| xargs -d '\n' -I {} find {} -name '*.ogg'
This solution was able to complete the search the quickest, and whilst it may not be as brief as the first response, is still succinct. Thanks to all who responded!
You could also set
IFS=$'\n'
and thenread line
, but that breaks on wildcards too when you use the filename again, so … yeah.exec
would be the most concise option. – slhck – 2012-02-20T21:43:02.927@slhck:
read
does not process wildcards, so I don't see how would it break when usingread line
. (The only place I can see is during expansion of the variable, which can be solved by double-quoting.) – user1686 – 2012-02-20T21:48:30.330Yeah I meant expansion, it wasn't the case for your answer anyway. Just something that can be easily forgotten. – slhck – 2012-02-20T21:57:53.247