On 27/11/10 17:14, Terry Coles wrote:

---8<---

> OK.  I've started trying to put together a script that will sort my tracks.  
> I've found two useful scripts on the web; one to create a list of filenames 
> in 
> a directory and one to parse out the ID3 tags.  I've started with the list of 
> filenames, but I have a problem.
>
> All of the existing files have been autogenerated by various tools and have 
> filenames like:
>
>       12 - Largo, from _the New World_.mp3
>
> When I just put one of these files into a Test directory and run the filename 
> script:
>
> #!/bin/bash
> directorytols=$1
>     for filename in $( ls "$directorytols")
>     do
>          if [ -d "$filename" ] ; then
>               echo "Directory: $filename"
>          elif [ -h "$filename" ] ; then
>               echo "Symlink: $filename"
>          else
>               echo "File: $filename"
>          fi
>     done
>
> I get:
>
> te...@beige:~/Scratch/Test$ ./ListDirectory MP3s
> File: 12
> File: -
> File: Largo,
> File: from
> File: _the
> File: New
> File: World_.mp3
>
> Clearly, this script is stumbling over the spaces in the filenames.
>
> Normally, I never put spaces in filenames, precisely to prevent problems like 
> this, but I didn't generate this filename (and I have over 600 files like 
> this).  Any thoughts on how to fix this?
>

Sorry to be lazy and just dump the text on you, but hopefully you can
adapt it:

#!/bin/bash

O=$IFS
IFS=$(echo -en "\n\b")
for each in `ls -1 *.wav`
do
    sox --norm "$each" -r 44100 -b 16 resampled_"$each"
done
IFS=$O

Right, off to cook the tea, so HTH!

Sean

-- 
music, film, comics, books, rants and drivel:

www.funkygibbins.me.uk


--
Next meeting:  Somewhere quiet, Bournemouth, ???day 2010-12-?? 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue

Reply via email to