Reverse dates in filenames using Total Commander’s multi-rename tool

Multi-rename tool in Total Commander is fantastic (when you know how to use it) and it saved my ass (before manually renaming many files) in many scenarios, including some very specific or even weird ones.

This scenario is one of such.

I had dates written directly as a part of filename, i.e.: Document name (DD-MM-YYYY).jpg, but (as shown) starting with day and ending with year. I had to reverse them, but only dates, keeping the rest of file untouched — i.e. Document name (YYYY-MM-DD).jpg.

At first, I thought that this time I will be forced to do this manually. But, I recalled multi-rename tool’s documentation and its small part about backward characters counting (i.e. from end of filename).

Actual file dates maybe incorrect due to many reasons or in many scenarios, i.e.:

  • Natural — scanning some doc months after it was actually issued
  • Stupid — bugs in Windows functionality which changes file date when you save the file

You can of course correct file’s date (as any other file attribute) in Total Commander (Windows even in version 10 still doesn’t have such functionality), but this is hard to achieve and may be changed in future, by some automatic process. While date kept as a part of filename will stay there until someone change it intentionally.

So the task was to change Document name (DD-MM-YYYY).jpg into Document name (YYYY-MM-DD).jpg. And do this as a batch processing task (i.e. using Total Commander’s multi-rename tool. Because I had 200+ files to be processed like that.

In short sharp words the string to be used as Rename mask: file name is:

[N1--13]([N-5,4]-[N-8,2]-[N-11,2])

With following parts:

  • [N1--13] — (filename from beginning until 13th character counting from end of file)
  • ( — bracket itself
  • [N-5,4] — four characters starting at the 5-last character, counted from the end of the name (year)
  • - — date separator
  • [N-8,2] — two characters starting at the 8-last character, counted from the end of the name (month)
  • - — date separator
  • [N-11,2] — two characters starting at the 11-last character, counted from the end of the name (day)
  • ) — closing bracket

This is most likely achievable much easier using regular expressions. Unfortunately, I don’t know pretty much nothing about them so the above approach was the only feasible option for me.

More information in Total Commander’s help (hit F1 when multi-rename tool is opened).

Leave a Reply