[NTLUG:Discuss] Basic script question

Patrick R. Michaud pmichaud at pobox.com
Wed Aug 10 14:35:30 CDT 2016


There's also the seq(1) command, which is less shell-specific:

   for i in $(seq -w 0 33)
   do
     echo "file$i.wav"
   done

The seq(1) command also allows formatting on the sequenced values directly, thus:

   seq -f "file%02g.wav" 0 33

or

   for i in $(seq -f "file%02g.wav" 0 33)
   do
     echo "Processing $i"
   done


Pm

On Wed, Aug 10, 2016 at 11:44:47AM -0500, Rusty Haddock wrote:
> FWIW, If you're using 'bash' or 'ksh' to number files with
> leading zeros in a loop can be done something like this:
> 
> for i in {00..33}
> 
> do
> 
>     echo Burp${i}.wav
> 
> done
> 
> 
> On Wed, Aug 10, 2016 at 11:16 AM, Fred James <fredjame at fredjame.cnc.net>
> wrote:
> 
> > Bobby Wrenn wrote:
> >
> >> "sox *.wav  output_file_name" works on my small set of sample files.
> >> Hopefully it will scale when I am in the jungle and off the grid. I am a
> >> little concerned that this may not take the files in proper sort order.
> >>
> >>
> >> On 08/10/2016 09:28 AM, Val W Harris wrote:
> >>
> >>> Bobby,
> >>>
> >>>
> >>> You didn;t say what distro you are using, but the CentOS 7 man page for
> >>> sox says that it accepts multiple input files.  Using a for loop to call
> >>> sox multiple times is overwriting the output of the previous call to sox.
> >>> Try
> >>>
> >>>
> >>> sox *.wav  output_file_name
> >>>
> >>> I hope this works for you.  Enjoy your adventure!
> >>>
> >>> --
> >>> Val Harris            valwharris at verizon.net
> >>>
> >>>
> >>>
> >>>
> >>> -----Original Message-----
> >>> From: Bobby Wrenn <bobby at wrennest.com>
> >>> To: NTLUG Discussion List <discuss at ntlug.org>
> >>> Sent: Wed, Aug 10, 2016 8:37 am
> >>> Subject: [NTLUG:Discuss] Basic script question
> >>>
> >>> Wondering if the list is still active. My first send of this post has
> >>> not appeared in my email.
> >>>
> >>> I need to set up why I am asking for help on a short notice.
> >>>
> >>> I am making a trip to the jungle of Papua New Guinea to make voice
> >>> recordings of people reading scripture in their native language. I will
> >>> be recording the whole book of Genesis with speakers for each character
> >>> in the book. I may do other books as well. In order to work with other
> >>> translation groups the files must be in a very specific format with a
> >>> predetermined file name sequence. After all the recordings are done I
> >>> need to retain the original chunks and assemble the chunks into
> >>> chapters. I can determine the start and stop filename for each chapter.
> >>> The files will be in a consistent WAV format. I expect to use sox to
> >>> join the WAV files for each speaker into a file for each chapter. I have
> >>> been planning this trip for some time. But just received this new
> >>> requirement to join the files today. I get on a plane tomorrow and will
> >>> have an Internet connection in country for about two days before I head
> >>> into the bush with solar panels and a laptop.
> >>>
> >>> I need help with a basic script to join the files given a start and stop
> >>> filename and an explicit output file name as parameters. Input file
> >>> names look like this "P1MSYPBT_01973.wav, P1MSYPBT_01974.wav, ...". The
> >>> output file will look like this "P1MSYPBT_001_GEN_01.wav,
> >>> P1MSYPBT_001_GEN_02.wav, ...".
> >>>
> >>> I tried putting the files for a chapter in a separate directory and
> >>> running [for i in *.wav;do sox "$i" P1MSYPBT_001_GEN_01.wav;done]. But
> >>> it either got only the first file or left out the last file. It was not
> >>> consistent.
> >>>
> >>> Any help greatly appreciated
> >>>
> >> Can you append a number to each file, in the sort order?
> >
> >
> > _______________________________________________
> > http://www.ntlug.org/mailman/listinfo/discuss
> >
> 
> 
> 
> -- 
>    _____
> |\/   o \   o           Rusty Haddock  <=>  AE5AE
> |   (  -<  O o          Somewhere in McKinney, TX
> |/\__V__/       Math illiteracy affects 7 out of 5 people!
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss



More information about the Discuss mailing list