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

Re: Using stupid filenames in shell scripts



On Thu, May 15, 2003 at 02:59:35PM +0200, Robert Ian Smit wrote:
> I have copied some mp3 containing directories from a windows
> partition. In the days I created those files it seemed like a good
> idea to use filenames such as:
> 
> 01 - Artist - Song1.mp3
> 02 - Artist - Song2.mp3
> etc.
> 
> When I want to do anything useful with these files, I'd like to use a
> script to avoid repeating the same action say 15 times.
> 
> For instance, I'd use something like:
> 
> for i in `ls`; do echo $i; done
> 
> This doesn't work properly. $i gets a lot of values like 01, -,
> Artist, Song.mp3 instead of one value per file.


Try the following:

   #!/bin/sh

   IFS=$'\n'

   for i in `ls -1b *.mp3`; do
      echo $i
   done
      
-- 
Jamin W. Collins

This is the typical unix way of doing things: you string together lots
of very specific tools to accomplish larger tasks. -- Vineet Kumar



Reply to: