How to change date format from "20230620" to "2023-06-20" ?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Roland
Junior Member
Junior Member
Posts: 7
Joined: 2005-10-05, 09:23 UTC
Location: Strasbourg, FRANCE

How to change date format from "20230620" to "2023-06-20" ?

Post by *Roland »

Good evening.

I don't find how (if it's even possible) to change date and hour format in file names.

I have files where the date and hour is the file name in the format "yyyymmdd_hhmmss".
For example 20230620_125237.jpg
Is there a way to automatically rename such files like this :
2023-06-20_12-52-37.jpg

Thank you in advance for any hint !

Roland
hi5
Power Member
Power Member
Posts: 637
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: How to change date and time format in file names ?

Post by *hi5 »

Select the files, press ctrl-m for the Multi Rename Tool, press F1 to read and study the help

Method 1 "easy" - Enter this in the NAME field

[N1-4]-[N5-6]-[N7-8]_[N10-11]-[N12-13]-[N14-15]

The preview should show the correct file names, press start.

OR

Method 2 "RegEx" - Tick the RegEx box

Enter this in the Search field

(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})

This in the replace

$1-$2-$3_$4-$5-$6

Preview OK? -> Start

You can save this solution so you can load it again via F2 Load/Save settings
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Roland
Junior Member
Junior Member
Posts: 7
Joined: 2005-10-05, 09:23 UTC
Location: Strasbourg, FRANCE

Re: How to change date and time format in file names ?

Post by *Roland »

Thanks for the answer !

Meanwhile I found another method that works :

In the rename tool , in the name field (the upper left field, called "Masque p. renom.: nom fichier" in french) I wrote [Y]-[M]-[D]_[h]-[m]-[s] and voilà this did the trick.
Total Commander seems smart enough to understand that my file name contains the date and the hour.

Your method 1 is nice too, method 2 is also interesting but a little too masochistic I think ! :lol:

Roland
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: How to change date and time format in file names ?

Post by *Hacker »

Roland,
Not really. Those placeholders take the date and time from the files' timestamps.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: How to change date and time format in file names ?

Post by *ghisler(Author) »

Indeed [Y]-[M]-[D]_[h]-[m]-[s] is NOT equivalent to the solutions posted by [b]hi5[/b]. Normally they are the same for unchanged photos (e.g. from a smart phone), but the file timestamp can change, e.g. when you resize or rotate and then save the image. Then [Y]-[M]-[D]_[h]-[m]-[s] will change the name to that new date and not the original date.
Author of Total Commander
https://www.ghisler.com
Post Reply