In an iOS Project with folders containing *.m files, similar to packages, one will have to run
genstrings -o en.lproj *.m
for each folder and match the relative en.lproj path. Is there a command that will do the drill down from the root folder?

- 63,694
- 13
- 151
- 195

- 1,373
- 2
- 13
- 24
4 Answers
You can concatenate all of the *.m files into one file and then call the genstrings on that.
I.E:
find . -name "*.m" -exec cat {} >> all.txt \;

- 155,636
- 47
- 315
- 299
-
i have created file with your instructions but unable to use genstrings command on that. can you please elaborate the line to deal with txt file ? – IDev May 18 '15 at 08:11
In Greenwich we use find
piped to xargs
. You can see how that's done here, but it's basically:
find "path/to/directory" -name "*.m" -print0 |
xargs -0 genstrings -s NSLocalizedString -o "path/to/output.strings"
I'd also recommend taking a look at Greenwich as it makes the whole process of localization much easier.

- 22,383
- 2
- 34
- 40
For me, this line just solved all problems. You even don't need to copy all m-Files to one document, before running the line in the shell. Just step into your project folder and run it, and all even the subfolders will be checked:
find . -name \*.m | xargs genstrings -o "directory/"
just create the directory before running it, otherwise you get an exception.

- 6,014
- 5
- 44
- 74
-
Works with Xcode11, iOS13, swift: find . -name \*.swift | xargs genstrings -o "directory/" – norbDEV Oct 31 '19 at 09:07
if you have a simple folder struct you probably get away with a simple
genstrings -ao <destination> <root>/*/*.m
using one *
for each level of subfolder.
Alternatively and if the folders have different nesting levels you are better off using:
find <root>/* -iname "*.m" -type f -print0 | xargs -0 genstrings -ao <destination>

- 3,042
- 1
- 16
- 26