Renaming multiple files at once (discarding suffix of the filename after a character)

Hi,

I have a lot of files similar to the below order. I want to rename all the files .discrading the time stamp/numbers after cnf.

Existing files

id_info_20130405.cnf_20130801
in_info_20130405.cnf_20130891
iz_info_20130405.cnf_20130821
in_info_20130405.cnf_20130818
rz_info_20130405.cnf_20130815
mn_info_20130405.cnf_20130809I

Desired filenames

id_info_20130405.cnf
in_info_20130405.cnf
iz_info_20130405.cnf
in_info_20130405.cnf
rz_info_20130405.cnf
mn_info_20130405.cnf

Try:

for f in *.cnf_*; do
  mv "$f" "${f%_*}"
done
1 Like

Thank you...Its working