[Gllug] Finding files in directories recursively

Jon Dye jon at pecorous.co.uk
Wed Jun 25 10:03:12 UTC 2008


Hi,

I want to run a program (mp3gain) passing it all the files in a
particular directory.  I then want to do this recursively, e.g.

given
dir1\file1
     file2
     file3
dir2\file1
     file2
     file3
dir3\dir4\file1
          file2
          file3

I want to run:
mp3gain dir1\file1 dir1\file2 dir1\file3
mp3gain dir2\file1 dir2\file2 dir2\file3
mp3gain dir3\dir4\file1 dir3\dir4\file2 dir3\dir4\file3

I was attempting something like this using xargs and find:
find / -type d -print0 | xargs -I{} -0 find {} -maxdepth1 -type f
-print0 | xargs -0 mp3gain

But this doesn't work because the last xargs just gets a list of all
files, not files grouped by directory.  I then thought I could run a
subshell
find / -type d -print0 | xargs -I{} -0 \(find {} -maxdepth1 -type f
-print0 | xargs -0 mp3gain\)
but that doesn't work because xargs expects a program not a shell script.

Does anyone have a suggestion as to how I can do what I want?

To make it harder, some directories and files contain spaces :-)

JD
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list