Keyboard shortcut for inserting date when editing file names

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

deckard
Junior Member
Junior Member
Posts: 80
Joined: 2003-10-10, 09:18 UTC

Keyboard shortcut for inserting date when editing file names

Post by *deckard »

I often put the current date in filenames and would really like to have a keyboard shortcut for inserting the date (formatted according to Windows' regional settings) when editing a file name. Like in Excel, when you press CTRL+SHIFT+, (comma). It's a real time saver in Excel, and would be in TC too! :D

Thanks for an amazing application!
User avatar
Stefan2
Power Member
Power Member
Posts: 4158
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Keyboard shortcut for inserting date when editing file names

Post by *Stefan2 »

cyberzip wrote: 2018-08-26, 21:06 UTC ...like to have a keyboard shortcut for inserting the date ...
Alternatives

You know you can create file and folder by utilizing Shift+F4 and F7 with current time stamp? (newer TC versions)
<My folder name-[Y]-[M]-[D]-[hms]

Also you can create user defined commands to create file and folder with current time stamp by just a click or a keyboard shortcut?
I also have "touchMe" scripts to add timestamps to already existing files.


For really "to insert" into the Shift+F4 / F7-dialogs you can utilize AutoHotkey.
SendTimestamp.ahk

Code: Select all

;FormatTime, OutputVar [, YYYYMMDDHH24MISS, Format]
FormatTime, OutputVar , ,yyyy-MM-dd-HHmmss
;Execute on 'Win+N ' key press
#n::
Send %OutputVar%


 
User avatar
tuska
Power Member
Power Member
Posts: 3757
Joined: 2007-05-21, 12:17 UTC

Re: Keyboard shortcut for inserting date when editing file names

Post by *tuska »

2cyberzip
Maybe that will help you too: SHIFT+U <ENTER> (Rename files)

Define your desired date format:
  • Files - Multi-Rename Tool... Ctrl+M --> opens MUT (Multi-Rename Tool)
  • Rename mask: file name --> [Y]-[M]-[D]_[N] ... define your desired format ...
  • F2 Load/save settings > Save settings: e.g. YYYY-MM-DD_Filename, OK, Close
Create an em_command:
(If you want to assign a shortcut to a command, you must first create an em_command).
  • Type in: cm_CommandBrowser <ENTER> in command line of TC
  • Type in: multirename in the field "Filter:" to determine the internal commands with parameters
  • Clear field "Filter:"
  • Click on usercmd.ini (under Category)
  • Click on button "New..." - new command name, e.g.: em_YYYY-MM-DD_Filename
  • OK, Command: MULTIRENAME em_YYYY-MM-DD_Filename
  • Tooltip: MULTIRENAME em_YYYY-MM-DD_Filename|viewtopic.php?f=14&t=50860
  • OK, OK
Create a shortcut:
  • Menu "Configuration" - "Options..." - "Misc." - Redefine hotkeys (Keyboard remapping)
  • Choose your hotkey(s) by clicking the appropriate field(s), e.g. [x] Shift + U - "Default command (no remapping)" is shown then
  • Click on the magnifying glass to the right - click on "usercmd.ini" - choose your em_command: em_YYYY-MM-DD_Filename - OK
  • IMPORTANT: click on the green checkmark! - OK - FINISHED!
After marking a single file or multiple files, they can be renamed using SHIFT+U <ENTER>.
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Re: Keyboard shortcut for inserting date when editing file names

Post by *HolgerK »

2tuska
MRT creates a date based on the modification date of the file, not the current date!

Regards
Holger
Make our planet great again
User avatar
tuska
Power Member
Power Member
Posts: 3757
Joined: 2007-05-21, 12:17 UTC

Re: Keyboard shortcut for inserting date when editing file names

Post by *tuska »

HolgerK wrote: 2018-08-27, 09:02 UTC 2tuska
MRT creates a date based on the modification date of the file, not the current date!

Regards
Holger
Ahh, yes, you are right! :oops:
Sorry!

(To my apology: I usually store files or create files and execute the shortcut immediately on the same day.)

Regards
Karl
Last edited by tuska on 2018-08-27, 09:46 UTC, edited 2 times in total.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Keyboard shortcut for inserting date when editing file names

Post by *ghisler(Author) »

Actually you can use placeholders [T1], [T2] and [T3] to control which date is inserted. From the help:

[T1] After this position, use last modification date/time from renamed file for all date/time fields (default).
Note: These are just switches! Use them with the other time placeholders, e.g. [T1][YMD] [hms]
[T2] After this position, use current date/time (when rename dialog was opened)
[T3] After this position, use current date/time (when rename options were last changed)
Author of Total Commander
https://www.ghisler.com
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Keyboard shortcut for inserting date when editing file names

Post by *Horst.Epp »

tuska wrote: 2018-08-27, 09:25 UTC
HolgerK wrote: 2018-08-27, 09:02 UTC 2tuska
MRT creates a date based on the modification date of the file, not the current date!

Regards
Holger
Ahh, yes, you are right! :oops:
Sorry!

Regards
Karl
The modification date is more useful for this purpose.
I use a shell extension (ShimExt) which does rename or copy with the modification date and find it very useful.
Its easier to handle using a context menu compared to using the MRT.
Also it can be customized for date format and what date should be used.
https://www.8charmax.com/shimext/
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
TvE
Junior Member
Junior Member
Posts: 8
Joined: 2022-03-17, 22:53 UTC
Location: Denmark

Re: Keyboard shortcut for inserting date when editing file names

Post by *TvE »

Old thread - but was indeed very usefull for me, this is the first time I'm extending the functionalty of TCM (should have done this ages ago)

Here's my notes (replicating most of alredy presented here...) - hope they're used by others that like to prepend their filenames with the current data+time (and also remove it in order to update it). Org mode have a great feature for editing these kind of data, but that's another story.



How to quickly prepend a filename with a time+date stamp

Create two settings in the MultiFileRename menu (Ctrl+M, F2)

Code: Select all

1. Prepend _YYYY-MM-DD_hhmmss _
    Rename Mask : [=tc.writedate.Y-M-D_hms] [N]
    RegEx       : N/A

Code: Select all

2. Remove _YYYY-MM-DD_hhmmss_ from start
    Rename Mask : [N]
    Search for  : (\d{4})-(\d{2})-(\d{2})_(\d{6})( +)(.*)
    RegEx       : Enabled


Create a custom command

Code: Select all

1. Launch cm_CommandBrowser
2. In Category select "usercmd.ini"
3. Create a new entry "em_prepend_date_time_to_filename"
    Command: "MULTIRENAME 1. Prepend _YYYY-MM-DD_hhmmss _"
    Tooltip: "Prepend Date & Time to the filename"

Add a generic shortcut for the custom command

Code: Select all

1. Select Configuration -> Options -> Misc.
2. Select hotkey = CTRL+ALT+D
3. Click search button
4. In Category select "usercmd.ini"
5. Select the just created command "em_prepend_date_time_to_filename"
6. Click OK
7. Click the green tick mark
8. Click OK

Now it's possible to prepend the date+time stamp from the "normal file-window:

Code: Select all

1. Select files
2. Press CTRL+ALT+D
3. Press OK
4. Press ESC

AND directly in the Multi File Rename window (eg for removal of the date time stamp)

To ADD the <DateTime> stamp

Code: Select all

    1. Select files
    2. CTRL+M   => Launch Multi Rename Files
    3. F2       => Load settings
    4. 1        => Select preset "1. Prepend _YYYY-MM-DD_hhmmss _"
    5. Enter    => Perform the rename
    6. F5       => Refresh the view to see the renamed files


To REMOVE the <DateTime> stamp

Code: Select all

    1. Select files
    2. CTRL+M   => Launch Multi Rename Files
    3. F2       => Load settings
    4. 2        => Select preset "2. Remove _YYYY-MM-DD_hhmmss_ from start"
    5. Enter    => Perform the rename
    6. F5       => Refresh the view to see the renamed files


Note to self: The config ends up here:

Code: Select all

    %APPDATA%\Roaming\GHISLER\usercmd.ini
    %APPDATA%\Roaming\GHISLER\wincmd.ini

Source: viewtopic.php?t=50860
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Keyboard shortcut for inserting date when editing file names

Post by *petermad »

A quick way of inserting the date in the file name for single files is this Button:

Code: Select all

TOTALCMD#BAR#DATA
cm_RenMov
/GT="%|$DATE:Y-M-D_h.m.s|_%N"W="%N"
WCMICONS.DLL,32
Prepend name of the file under the cursor with current date and time
To make the button:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".
Requires TC 11.0 or newer
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2296
Joined: 2020-01-18, 04:03 UTC

Re: Keyboard shortcut for inserting date when editing file names

Post by *Fla$her »

petermad wrote: 2024-02-11, 01:38 UTC _%N"W="%N"
:?: :shock: How does this work for you? _%Q%N" is enough here.
Overquoting is evil! 👎
sa16
Senior Member
Senior Member
Posts: 217
Joined: 2021-09-10, 07:15 UTC

Re: Keyboard shortcut for inserting date when editing file names

Post by *sa16 »

2TvE

Code: Select all

"MULTIRENAME 1. Prepend _YYYY-MM-DD_hhmmss _"
So not more convenient?

Code: Select all

"MULTIRENAME == 1. Prepend _YYYY-MM-DD_hhmmss _"
12.04.22 Release Total Commander 10.50 beta 1
28.02.22 Added: command MULTIRENAME==<settings> with two equal signs now starts renaming immediately and closes the dialog if successful (32/64)
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Keyboard shortcut for inserting date when editing file names

Post by *petermad »

Fla$her wrote: 2024-02-11, 03:07 UTC How does this work for you? _%Q%N" is enough here.
It works fine, but you are right the W="%N" part is not necessary - it was left over from tests where I tried to make it work for several files. And of course we need %Q - I just never use spaces in file names so i forgot about it.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
sa16
Senior Member
Senior Member
Posts: 217
Joined: 2021-09-10, 07:15 UTC

Re: Keyboard shortcut for inserting date when editing file names

Post by *sa16 »

2petermad
I tried to make it work for several files.
Just not as in the examples:

Code: Select all

TOTALCMD#BAR#DATA
cm_Renmov
/GT="???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????_%|$DATE:Y-M-D_h-m-s|.*"
WCMICONS.DLL,32
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Keyboard shortcut for inserting date when editing file names

Post by *petermad »

2sa16
Just not as in the examples:
Exactly - I don't think it is possible using cm_Renmov without any third party programs.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
TvE
Junior Member
Junior Member
Posts: 8
Joined: 2022-03-17, 22:53 UTC
Location: Denmark

Re: Keyboard shortcut for inserting date when editing file names

Post by *TvE »

@sa16
Awesome - I just came back to post an update to my config and learned about `==´
I'll post the complete guide here

Changes
- Addedd `==´ for commands to take effect immediately
- Added shortcut for prepending DATE only


Create three settings in the MultiFileRename menu (Ctrl+M, F2)

First

Code: Select all

    "0. Prepend _YYYY-MM-DD _"
        Rename Mask : [T2][Y]-[M]-[D] [N]
        RegEx       : N/A
Second

Code: Select all

    "1. Prepend _YYYY-MM-DD_hhmmss _"
        Rename Mask : [T2][Y]-[M]-[D]_[h][m][s] [N]
        RegEx       : N/A
Third

Code: Select all

    "2. Remove _YYYY-MM-DD_hhmmss_ from start"
        Rename Mask : [N]
        Search for  : (\d{4})-(\d{2})-(\d{2})(_\d{6}){0,1}( +)(.*)
        RegEx       : Enabled


Create two custom commands

Code: Select all

1. Launch cm_CommandBrowser
2. In Category select "usercmd.ini"
3. Create a new entry "em_prepend_date_to_filename"
    Command: "MULTIRENAME == 0. Prepend _YYYY-MM-DD _"
    Tooltip: "Prepend Date to the filename"
4. Create a new entry "em_prepend_date_time_to_filename"
    Command: "MULTIRENAME == 1. Prepend _YYYY-MM-DD_hhmmss _"
    Tooltip: "Prepend Date & Time to the filename"
Add generic shortcuts for the custom commands

Code: Select all

1. Select Configuration -> Options -> Misc.
2. Select hotkey = CTRL+ALT+D
3. Click search button
4. In Category select "usercmd.ini"
5. Select the just created command "em_prepend_date_to_filename"
6. Click OK
7. Click the green tick mark
8. Click OK
9. Select hotkey = CTRL+ALT+SHIFT+D
10. Click search button
11. In Category select "usercmd.ini"
12. Select the just created command "em_prepend_date_time_to_filename"
13. Click OK
14. Click the green tick mark
15. Click OK
OR add these two lines to %APPDATA%/GHISLER/wincmd.ini

Code: Select all

[Shortcuts]
CAS+D=em_prepend_date_time_to_filename
CA+D=em_prepend_date_to_filename



Now it's possible to prepend the date/date+time stamp from the "normal" file-window:

Code: Select all

1. Select files
2a. Press CTRL+ALT+D (for date)
2b. Press CTRL+ALT+SHIFT+D (for date+time)

AND directly in the Multi File Rename window (eg for removal of the date time stamp)
(I could make a direct shortcut to the "remove", but I think my main use case is to ADD, not remove, the data/time stamp...)

To ADD the <Date> stamp

Code: Select all

    1. Select files
    2. CTRL+M   => Launch Multi Rename Files
    3. F2       => Load settings
    4. 0        => Select preset "0. Prepend _YYYY-MM-DD _"
    5. Enter    => Perform the rename
    6. F5       => Refresh the view to see the renamed files

To ADD the <DateTime> stamp

Code: Select all

    1. Select files
    2. CTRL+M   => Launch Multi Rename Files
    3. F2       => Load settings
    4. 1        => Select preset "1. Prepend _YYYY-MM-DD_hhmmss _"
    5. Enter    => Perform the rename
    6. F5       => Refresh the view to see the renamed files

To REMOVE the <DateTime> stamp

Code: Select all

    1. Select files
    2. CTRL+M   => Launch Multi Rename Files
    3. F2       => Load settings
    4. 2        => Select preset "2. Remove _YYYY-MM-DD_hhmmss_ from start"
    5. Enter    => Perform the rename
    6. F5       => Refresh the view to see the renamed files


Note to self: The config ends up here:

Code: Select all

    %APPDATA%\Roaming\GHISLER\usercmd.ini
    %APPDATA%\Roaming\GHISLER\wincmd.ini

Source: viewtopic.php?t=50860

2024-02-25 1213 UPDATE
Changed the two snippets from

Code: Select all

[=tc.writedate.Y-M-D_hms] [N]
to

Code: Select all

[T2][Y]-[M]-[D]_[h][m][s] [N]
as I just learned that the former results in the timestamp from when the file was created (or modified?) and I want to get the Wall Clock Time (which [T2] is so kind as to give me)
Last edited by TvE on 2024-02-25, 11:16 UTC, edited 1 time in total.
Post Reply