Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use genstrings across multiple directories?

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?

like image 590
dontWatchMyProfile Avatar asked Apr 30 '10 12:04

dontWatchMyProfile


3 Answers

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.

like image 145
Brian King Avatar answered Oct 20 '22 06:10

Brian King


I don't know exactly why, but Brian's command didn't work for me. This did:

find . -name \*.m | xargs genstrings -o en.lproj

EDIT: Well, when I originally wrote this I was in a hurry and just needed something that worked. The issue that was occurring for me when using the accepted answer above was that "*.m" has to be quoted (and the curious can find an explanation as to why this is the case in the comments on Brian King's answer). I think that the best solution is to use that original answer with the appropriate bit quoted, which would then read:

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

I'm leaving my original reply intact above though, in case it still helps anybody for whatever reason.

like image 93
Jonathan Zhan Avatar answered Oct 20 '22 05:10

Jonathan Zhan


This works for me:

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

Thanks to Brian and Uberhamster.

like image 18
SEG Avatar answered Oct 20 '22 07:10

SEG