Re: Using stupid filenames in shell scripts
On Thursday 15 May 2003 14:59, 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.
Ah. Very windowsish behaviour. ;)
> 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.
You have to put the $i in double-quotes. The right script is
for i in *.mp3; do echo $i; done
Also,
mpg123 *.mp3
should work...
If you are going to produce new mp3's, you will consider naming them without
spaces. Just replace all spaces with underscores _ . If you want to know how
to rename all existing files, wait for Colin Watson to answer, he is
something like the "script guru" over here. Maybe he will also explain how
quoting works in bash, I have read the man page, but I still don't understand
it :(
joerg
--
Gib GATES keine Chance!
Reply to: