Is there an easy way to change in a linux console the date format in a file name?

Eg. I have a bunch of files which contain a date (DD-MM-YYYY) in the file name like:


and I want to change it to YYYY-MM-DD:


I was looking for a bash script I can must apply in the a folder with several files.

1 Answer 1


With Perl's rename:

rename 's/([0-9]{2})-([0-9]{2})-([0-9]{4})/$3-$2-$1/' *.pdf

See: man rename

  • 1
    Thx, that's what I was looking for. I didn't know that it is that easy. I changed the example code a little to make it more general and to apply it on all files which the ending *.pdf.
    – wittich
    Aug 20, 2016 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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