This question already has an answer here:

I have files with names as,


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?

marked as duplicate by jasonwryan, slm, Anthon, Timo, rahmu Apr 3 '14 at 11:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.