How to use genstrings across multiple directories?

dontWatchMyProfile picture dontWatchMyProfile · Apr 30, 2010 · Viewed 32.9k times · Source

I have an directory, which has a lot of subdirectories. those subdirs sometimes even have subdirs. there are source files inside.

How could I use genstrings to go across all these dirs and subdirs?

Let's say I cd to my root dir in Terminal, and then I would type this:

genstrings -o en.lproj *.m

How could I tell it now to look into all these directories? Or would I have to add a lot of relative paths comma separated? how?

Answer

Brian King picture Brian King · Apr 30, 2010

One method would be:

find ./ -name "*.m" -print0 | xargs -0 genstrings -o en.lproj

xargs is a nice chunk of shell-foo. It will take strings on standard in and convert them into arguments for the next function. This will populate your genstrings command with every .m file beneath the current directory.

This answer handels spaces in the used path so it is more robust. You should use it to avoid skipping files when processing your source files.

Edit: as said in the comments and in other answers, *.m should be quoted.