remove the file name dots in linux

April 6, 2011 at 09:20:48
Specs: Windows XP
I have a file names as 123.456.789.jpg there are many files like this......i want to remove all dots except the last one......could you please let me know how can i do that

See More: remove the file name dots in linux

Report •

#1
April 6, 2011 at 10:22:28
A way: once you are sure this bash script works, change the cp command to mv:

#!/bin/bash

myext=".jpg"
ls -1 *$myext|while read file
do
   bn=$(basename "$file" $myext )
   mynewfile=$(echo "$bn"|sed 's/\.//g')
   cp  "$file" "$mynewfile$myext"
done


Report •
Related Solutions


Ask Question