Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

alternative method for a simple for



Background:

I was just playing around and trying to find an alternative way to accomplish the following simple for loop:

$  for file in *.wav
for>      do
for>      ffmpeg -b 160k -i $file  ${file:r}.mp3
for>      done


(Method 1.) Note that I could not not use this method as shown below
  $ zmv -p ffmpeg -o " -b 160k -i" '(*).wav' '$1.mp3'

because it puts two hypens, "--", between -i and filename, as below:
     ffmpeg -b 160k -i -- song1.wav song1.mp3
     ffmpeg -b 160k -i -- song2.wav song2.mp3

--------

(Method 2.) Likewise I could not use zargs, yet at least,
     because replacements or expansions //l/r or :r didn't seem to work..

$ zargs --replace=arg -e.. -- *.wav .. ffmpeg -b 160k -i arg ${${file::=arg}//.wav/.mp3}

produces:
     ffmpeg -b 160k -i song1.wav  song1.wav
     ffmpeg -b 160k -i song2.wav  song2.wav


and both of 
$ zargs --replace=arg -e.. -- *.wav .. echo -b 160k -i arg ${${file::=arg}:r}.mp3
and
$ zargs --replace=arg -e.. -- *.wav .. echo -b 160k -i arg arg.mp3

produces the below with .mp3 appended, but .wav not taken off first.
     ffmpeg -b 160k -i Chaos-Voices-Music.wav Chaos-Voices-Music.wav.mp3
     ffmpeg -b 160k -i Dave-s_Song-Part_2.wav Dave-s_Song-Part_2.wav.mp3


I can't help thinking that zargs could handle this if someway, but I don't know how to yet.   Just wondering if anyone had any suggestions.

Thanks,
  Darel Henmanm



Messages sorted by: Reverse Date, Date, Thread, Author