[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: bash vs. python scripts - which one is better?



On Wed, Aug 08, 2007 at 10:29:27AM +0100, Jon Dowland wrote:
> 
> > IFS=$'\t\n'; for i in `find . -iname \*m4a`; do faad...
> > blah blah blah
> 
> > and I knew it was a hack because setting $IFS just seems
> > bad... possible unintended consquences, but it worked.
> 
> it's the backtick sub-shell that stands out to me. As
> others have pointed out, find's -exec argument is very
> useful:
> 
>     find . -iname '*m4a' -exec faad .... {} \;
> 
> However I haven't used it in a long time, preferring to
> instead use -print0 and xargs -r0
> 
>     find . -iname '*m4a' -print0 | xargs -r0 -n1 faad ...
> 
> In many cases (such as the mass-gzip someone else provided)
> xargs will be significantly more efficient as it will only
> spawn as many sub-processes as is required. In your faad
> example, I expect you need one faad process per input file,
> so -n1 is necessary.

well that's the first in a long line of statements operating on $i,
extracting tag information from .m4a, converting to .mp3 (I know I
know, don't start, its got to do with the WAF, conformance with
existing 40GB library etc etc), parsing tag information for proper
retagging, and finally removing the originals, all nice and pretty so
she can just plunk the files down somewhere and have them magically
appear ready to go. 

Anyway, I'm not sure I would gain much by mashing it all into one find
-exec... I'd certainly lose readability. ;)


A

Attachment: signature.asc
Description: Digital signature


Reply to: