[GLLUG] Recursive directory search with bash

Edward Glowacki glowack2 at msu.edu
Wed Nov 24 12:36:43 EST 2004


Mike Simons wrote:

> I'm trying to setup an iTunes share on my linux box using daapd.  For 
> some reason though, the developers didn't have the program recursively 
> search the directory given in /etc/daapd.conf for audio files.   
> Instead of modifying the source to do this myself,  I want to just 
> make a script to recursively search a certain directory for audio 
> files  and then symlink them to a different directory that I can point 
> daapd to.  The only problem I'm having with making a script is finding 
> some way to recursively search the directories.  The files are 
> organized in folders arccording to artist->albums->songs  so it is 
> easy to do a " ln -s * /web/itunes  " at the bottom of each 
> directory.    Any insight on the recursive search would be helpful.  
> Thanks.
>
> -Mike Simons

Look into the program "find".  Something like: find /where/my/tunes/are 
-name "*.mp3"

You should be able to do it all in one line with find's -exec option: 
find /tunes -name "*.mp3" -exec "ln -s {} /web/itunes" (haven't tested 
that, read the man page for find to make sure the syntax is correct and 
all...)

-ED


More information about the linux-user mailing list