Re: bash scripting question

From: Floyd Davidson (floyd_at_barrow.com)
Date: 08/10/03


Date: 09 Aug 2003 22:39:47 -0800

Francisco <fran575@mailandnews.com> wrote:
>Say I want to decode with lame a lot of files in one dir, I do the
>following:
>for n in `ls *.mp3`;do lame --decode $n; done
>
>This works great if files dont have spaces, but if there are spaces the
>scripts fails because $n cantains only the fragment of the files names
>until a space occur.
>So, is there a solution to this?, how should I do it?
>Thank you.

Put double quotes around $n

  for n in `ls *.mp3`; do lame --decode "$n"; done

However, there is no need to use ls as you have, just do

  for n in *.mp3; do lame --decode "$n"; done

Someone suggested using find, which will certainly work too. It
isn't needed unless you want to recurse sub directories or if
any of your files are "dot" files, like .hidden.mp3 which will
not be picked up using *.

-- 
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com


Relevant Pages

  • Re: bash scripting question
    ... On Sun, 10 Aug 2003 at 06:13 GMT, Francisco wrote: ... > Say I want to decode with lame a lot of files in one dir, ...
    (comp.os.linux.misc)
  • bash scripting question
    ... Say I want to decode with lame a lot of files in one dir, ... This works great if files dont have spaces, but if there are spaces the ... scripts fails because $n cantains only the fragment of the files names ...
    (comp.os.linux.misc)
  • Re: sample grabber question
    ... This works fine, but, I also need to decode m4a files. ... grabber does not seem to decode these and the files dont even play in my ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: sample grabber question
    ... This works fine, but, I also need to decode m4a files. ... Ths sample ... grabber does not seem to decode these and the files dont even play in my ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: bash scripting question
    ... > Say I want to decode with lame a lot of files in one dir, ... Then it doesn't matter if there are spaces in the filenames, ... the 'find' command to avoid recursing into subdirectories. ... may also work, and be slightly faster, if lame behaves the way I hope it ...
    (comp.os.linux.misc)