bug-bash
[Top][All Lists]
Advanced

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

File renaming using SED in BASH


From: MisterMuv
Subject: File renaming using SED in BASH
Date: Sun, 21 Sep 2008 14:55:09 -0700 (PDT)

Hi,

I am having a problem renaming a files using SED.

The filenames are in the following format: eg

001 - GreatPics1 (The Opening) (www.somewhere.net).jpg
002 - GreatPics2 (The Closing) (www.somewhere.net).jpg
003 - GreatPics3 (The Ending) (www.somewhere.net).jpg

I am wanting to remove contents of the second parenthesis, i.e.
"(www.somewhere.net)".

So the files would end up like:

001 - GreatPics1 (The Opening) .jpg
002 - GreatPics2 (The Closing) .jpg
003 - GreatPics3 (The Ending) .jpg

This is what I have so far.

If I use this to test all is well

for f in *
do
echo $f |sed 's:(www.somewhere.net)::'
done

However when I incorporate the mv command all isn't well.

for f in *
do
chg=echo $f |sed 's:(www.somewhere.net)::'
mv $f $chg
done

I get:
bash: 001: command not found
mv: target `(www.somewhere.net).jpg' is not a directory
bash: 002: command not found
mv: target `(www.somewhere.net).jpg' is not a directory
bash: 003: command not found
mv: target `(www.somewhere.net).jpg' is not a directory


What am I doing wrong?

Thankyou all in advance.
-- 
View this message in context: 
http://www.nabble.com/File-renaming-using-SED-in-BASH-tp19598886p19598886.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]