I have files with names as,
A2002185.h23v04.005.2007177004246.hdf
A2002201.h23v04.005.2008288062542.hdf
I want to rename them by deleting everything in the name after first dot (and have names as A2002185.hdf, A2002201.hdf), how can I do that?
Using prename
(rename
is a symlink to this by default on many systems):
prename -n 's:\..*\.:.:' *.hdf
The -n
will print the actions that will be taken without doing anything. Once you are sure you have what you want, remove it.
Run the below script from the folder where you have all these files.
for f in *.hdf; do mv -- "$f" "${f%%.*}".hdf ; done
The above script checks for all files with hdf
extension inside the current directory and for each file, it removes the characters after the .
character and adds the extension as .hdf