Have Problems adding an extension to files in a directory
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!!!!
Hi,
if you just have to add the ".edi" extension to all the files, you could do just this:
for $files in *.gtp.*
do
mv $files $files.edi
done
OR
for $files in *.gtp.*
do
NEWSUFFIX=".edi"
mv $files $files$NEWSUFFIX
done
Hope this helps,
Stef.
for ($i in *); do mv "$i" `basename "$i"`.edi; done