LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Renaming Multiple Files with a "." on the end of the filename (https://www.linuxquestions.org/questions/programming-9/renaming-multiple-files-with-a-on-the-end-of-the-filename-321748/)

dbowles 05-09-2005 04:02 PM

Renaming Multiple Files with a "." on the end of the filename
 
I am trying to port several thousand files from a linux workstation to a windows workstation. The windows workstation refuses to work with files that have a "." at the end of the filename. I have tried to write a shell script but it does not seem to work. Is there an easier way to remove the "." at the end of the filename or do am I writing my regular expression wrong?

for i in `ls *.`; do
t=`echo i$ | sed 's/\(.*\)/\1/'`
mv $i $t
done

Thanks,

David B.

Hko 05-09-2005 04:28 PM

Code:

for i in *. ; do
        t=`echo $i | sed 's/\.$//'`
        mv $i $t
done

Or, a little smaller and faster, but bash-only:
Code:

for i in *. ; do
        mv $i ${i%.}
done



All times are GMT -5. The time now is 12:03 PM.