Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Batch text conversion with textutil' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Batch text conversion with textutil
Authored by: pc_junk on Mar 14, '06 12:57:45PM

Very minor suggestion however it would be much more efficient to use xargs to batch up the conversions. The current command will execute textutil for each file - as textutil will accept multiple files you can do something like -

find . -name \*.doc -print0 | xargs -0 textutil -convert txt

This will create a textutil command line upto the max length allowed by the OS allowing multiple conversions to run in a single process rathen than forking a separate instance for each file. The -print0 & -0 args will allow filenames containing spaces to be passed correctly. Also you need to escape the wildcard in the find statement.

xargs tends to be a rather overlooked utility but can be very useful !





[ Reply to This | # ]
10.4: Batch text conversion with textutil
Authored by: SOX on Mar 14, '06 10:41:38PM

I don't get it. Xargs simply puts one line onto the command line at a time. -0 says the argument spacing is delmited by nulls . and print0 replaces the newlines with nulls. So this will put all of the find results onto a single line. How does xargs know when the line buffer is overflowed and it needs to go to re-invoke the command again. Can't find this documented.



[ Reply to This | # ]
10.4: Batch text conversion with textutil
Authored by: hopthrisC on Mar 15, '06 02:45:16AM
Why do want this documented? Isn't it enough to know that xargs does know about the limits of the command line length?

If you are really interested, read the source.

[ Reply to This | # ]

10.4: Batch text conversion with textutil
Authored by: pc_junk on Mar 16, '06 12:16:49PM

It gets this from sysconf(3) -

_SC_ARG_MAX
The maximum bytes of argument to execve(2).



[ Reply to This | # ]