|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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!!!! |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
for ($i in *); do mv "$i" `basename "$i"`.edi; done
is my "standard rename function"
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Have Problems adding an extension to files in a directory |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|