Remove characters from file name

Here is my code.

for file in *1.3.html ; do mv "$file" `echo $file | tr '.1.3' ''` ; done

For some reason I am getting an error.

mv: file.idlesince.1.3.html and file.idlesince.1.3.html are identical

Could this be done a different way?

Apparently, the tr command is not doing what was inteded to do

You may want to use sed.

for file in *1.3.html ; do des=$(echo $file | sed 's/\.1\.3//g' );mv "$file" "$des" ; done

cheers,
Devaraj Takhellambam

You can also try this?

for file in 1.3.html ; do mv "$file" ${file%%.}.html ; done

I noticed just now you wanted to keep the 'idlesince'? as in file.idlesince.html and remove everything after 1.3...?

Then technically this should be what you want:

for file in *1.3.html ; do mv "$file" ${file%%1*}html ; done

tr translates characters, not strings.

for file in *.1.3.html
do
   mv "$file" "${file%.1.3.html}.html"
done

Thanks for the responses.