Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have Problems adding an extension to files in a directory

Status
Not open for further replies.

dshaw21369

Programmer
Jul 8, 2002
64
0
0
I'm Trying add an .edi extenion to the file that originally looks like this: i.gtp.030206065504
I would like it to look like this: i.gtp.030206065504.edi


When using this code Im getting the error: Cannot rename *gtp.* to *gtp.*edi:

This is my code:


OLDSUFFIX=
NEWSUFFIX=edi
for FILES in *gtp.*"$OLDSUFFIX"
do
NEWNAME=`echo "$FILES" | sed -e "s/${OLDSUFFIX}\$/$NEWSUFFIX/"`
mv "$FILES" "$NEWNAME"
done

Any Suggestions would be appreciated!!!!
 
how about:
Code:
for i in *gtp*; do
  mv "$i" "$i".edi
done
the "" are tossed in to accomodate spaces in the filenames. remove them if not necessary or cause any problems.
--
JR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top