Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

They're named with date '+%d-%m-%Y, %a, %k.%M.%S'. I'm looking to rename them to date '+%Y-%m-%d, %a, %H.%M.%S'.

share|improve this question
up vote 0 down vote accepted

Use the prename command:

prename 's/^(..)-(..)-(....)/$3-$2-$1/; s/  / 0/' [list of files]

This will capture the day, month, year and rewrite it in year, month, day order. Then it will take all occurences of double spaces (which only occurs before the hour, and only it hour is <10, when formatted with %k) and transform it to " 0", which in practice makes it equivalent to %H.

prename is a Perl script included in most standard Perl installations (in my experience) and is thus probably already present on your system. It is often (e.g. on Debian based systems) linked to rename.

Use the -n (--no-act) switch to prename the first time you run it to only show what changes will be done when the switch is removed.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .