I need to rename my files in Linux from date.time.filename to filename.


20170310.00.35.06.Samridhi to Samridhi

  • 1
    Are files in same directory ? or there's more than one level ? Mar 10 '17 at 8:55
  • 1
    Do all files have Samridhi ending ? or are endings different ? If they're all the same you are risking overwriting all files into one. Mar 10 '17 at 8:56
  • 3
    Possible duplicate of How to easily rename files using command line?
    – karel
    Mar 10 '17 at 9:04
  • @karel why the generic dupe? it's a specific question...
    – Zanna
    Mar 10 '17 at 9:08
  • 1
    Why do we need to reinvent the wheel? Simplest possible generic rename question deserves the simplest possible generic rename answers which are found in the linked duplicate question, specifically pyRenamer.
    – karel
    Mar 10 '17 at 9:14

You could remove the date and time using an exact expression if the format is consistent, then you will be left with the filename part no matter what characters it has.

rename -n 's/^\d{8}\.\d{2}\.\d{2}\.\d{2}\.//' *

remove -n after testing to actually rename the files.


  • \d{8} exactly 8 digits
  • \. literal .

Thanks to @terdon for pointing out that in rename we can use \d to represent any digit instead of [0-9]


The mv move command is what you need - it'll move a file to another directory and/or rename it (in the same directory).

So in the directory with your file, type:

mv -vi 20170310.00.35.06.Samridhi Samridhi.

The -v option will show you what it's doing, while the -i option will complain if a file with the same name already exist, allowing you to decide if you want to overwrite it or not.

There is also a rename-command, but this is more useful if you have a lot of files that you want to change the name of after som pattern. Eg. files called document.txt.001, document.txt.002, document.txt.003 ... document.txt.050 ; and you'd rather would have files called document-001.txt, document-002.txt and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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