newbie problem for renaming files using a bash script
- From: "Dazz Murphy" <dazz@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 3 Sep 2006 10:34:45 -0700
First of all i apologise for duplicating the post to this
group(previously posted to gnu.bash), i realised after posting it this
was a more apropriate group to post to.
----------------------------- original post
-----------------------------------
I'm trying to write a bash script to rename files in the directory i'm
running the script from but have hit a problem. The files are my own
purchased cd's that i'm ogg encoding using sound juicer cd ripper, the
problem being it uses uppercase and spaces.
The script is as follows:
#!/bin/bash
for fname in *.ogg
do
FormattedName=$(echo ${fname//" "/"\ "})
FormattedName=$(echo ${FormattedName//"("/"\("})
FormattedName=$(echo ${FormattedName//")"/"\)"})
NewName=$(echo ${fname//' '/_} | tr A-Z a-z)
mv $FormattedName $NewName
done
when running the script with + x i get this output.
+ for fname in '*.ogg'
++ echo '13\' '-\' Comalies.ogg
+ FormattedName='13\ -\ Comalies.ogg'
++ echo '13\' '-\' Comalies.ogg
+ FormattedName='13\ -\ Comalies.ogg'
++ echo '13\' '-\' Comalies.ogg
+ FormattedName='13\ -\ Comalies.ogg'
++ echo 13_-_Comalies.ogg
++ tr A-Z a-z
+ NewName=13_-_comalies.ogg
+ mv '13\' '-\' Comalies.ogg 13_-_comalies.ogg
mv: invalid option -- \
the problem i have is that when i call mv the source filename appears
as '13\' '-\' Comalies.ogg not 13\ -\ Comalies.ogg as expected can you
help me please. I'm new to shell scripting but not to linux.
.
- Follow-Ups:
- Re: newbie problem for renaming files using a bash script
- From: Chris F.A. Johnson
- Re: newbie problem for renaming files using a bash script
- Prev by Date: Re: output
- Next by Date: Re: How do you echo a carriage return?
- Previous by thread: How do you echo a carriage return?
- Next by thread: Re: newbie problem for renaming files using a bash script
- Index(es):
Relevant Pages
|
|