Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jan 2018 22:17:54 +0700
From:      Victor Sudakov <vas@mpeks.tomsk.su>
To:        freebsd-questions@freebsd.org
Subject:   Re: Convert .flac and .ape to mp3
Message-ID:  <20180106151754.GA35747@admin.sibptus.transneft.ru>
In-Reply-To: <op.zce38vcag7njmm@workstation>
References:  <20180104163421.GA15692@admin.sibptus.transneft.ru> <20180104175156.440fa0c2.freebsd@edvax.de> <20180106063934.GA32231@admin.sibptus.transneft.ru> <op.zce38vcag7njmm@workstation>

next in thread | previous in thread | raw e-mail | index | archive | help
Michael Ross wrote:
> 
> 
> > So eventually I will need to write a script to process all the *.ape
> > files, probably with bchunk. Which brings the following question. If
> > the file and directory names have spaces in them, a simple loop like
> > this:
> >
> > #!/bin/sh
> > for i in `find . -iname '*.ape'`
> > do
> >   do_something $i
> > done
> >
> > breaks on spaces.
> >
> > What is the sh magic to handle such filenames?
> >
> 
> xargs, you may want to run a few conversions in parallel:
> 
> find . -iname '*.ape' -print0 | xargs -0 -I% -P<parallel_runs> convert %  %.mp3

I'm sure there are many ways to solve the problem, including writing a
C program, but a solution in pure sh has its own value and appeal.

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
AS43859



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180106151754.GA35747>