Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 87
Joined: 2024-11-03, 02:45 UTC

Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *xxxdo1 »

Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Usage scenario, for example:

Code: Select all

cmd=cm_RenameSingleFile
param=%O_%|$DATE:Y-M-D_h·m·s|.%E
So I can quickly rename a file.
Now I can only use this command, which is not very friendly if it is a large file.

Code: Select all

cmd=cm_RenMov
param=/PB2GO2SHT="%O_%|$DATE:Y-M-D_h·m·s|.%E"
Are there other ways to quickly rename a file?
hi5
Power Member
Power Member
Posts: 637
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *hi5 »

Have you tried using the Multi Rename Tool? Select a file, enter something like:

[T2][D][M][Y]
(see HELP for details)

in the NAME field, SAVE it as say "RenameToday".

Now you can use it in a button or menu or em_user command as

MULTIRENAME=RenameToday
(opens the MRT dialog)

or

MULTIRENAME==RenameToday
(executes the rename process and closes the dialog if there are no errors)
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)
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 87
Joined: 2024-11-03, 02:45 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *xxxdo1 »

2hi5
No, I need to quickly rename a single file for backup purposes, not batch rename
hi5
Power Member
Power Member
Posts: 637
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *hi5 »

That is exactly what it does - MRT also works on single files, I use it all the time like that. Have you actually tried it?
Assuming you won't select multiple files before starting the MRT it will work.
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)
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *Fla$her »

xxxdo1 wrote: 2025-01-25, 08:37 UTC

Code: Select all

param=/PB2GO2SHT="%O_%|$DATE:Y-M-D_h·m·s|.%E"
I wouldn't use P and H. B1 is better then B2 for renaming. Instead of O2 I would write O5, because there is no point in replacing another existing file when renaming.

Code: Select all

param=/B1O5SGT="%O_%|$DATE:Y-M-D_h·m·s|.%E"
xxxdo1 wrote: 2025-01-25, 08:37 UTC Are there other ways to quickly rename a file?

Code: Select all

TOTALCMD#BAR#DATA
%comspec% /q/c ren
%N "%O_%|$DATE:Y-M-D_h·m·s|.%E"
wcmicon2.dll,32
Add the date to the file/folder name under the cursor

1
If '_' is already at the end of the name, it will not be added:

Code: Select all

TOTALCMD#BAR#DATA
mshta "javascript:close(new
ActiveXObject('Scripting.FileSystemObject').getFile('%Q%N').name='%O'+('%O:~-1'=='_'?'':'_')+'%|$DATE:Y-M-D_h·m·s|.%E')"
wcmicon2.dll,32
Add the date to the file name under the cursor
Overquoting is evil! 👎
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 87
Joined: 2024-11-03, 02:45 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *xxxdo1 »

2hi5
I like the script method, it is easier and more convenient.


2Fla$her
Your other methods are also very good, I learned a lot. :D
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *Fla$her »

xxxdo1 wrote: 2025-01-25, 16:08 UTCI like the script method
Do you mean my last button? Good.

Switching example:

Code: Select all

TOTALCMD#BAR#DATA
mshta
"javascript:v='%O';new ActiveXObject('Scripting.FileSystemObject').getFile('%Q%N').name=(v.search(/_\d{4}(\-\d\d){2}_\d\d(·\d\d){2}$/)==-1?v+('%O:~-1'=='_'?'':'_')+'%|$DATE:Y-M-D_h·m·s|':v.slice(0,-20))+'.%E';close()"
wcmicon2.dll,32
Add/delete the date to/from the file name under the cursor
Last edited by Fla$her on 2025-01-27, 15:59 UTC, edited 1 time in total.
Overquoting is evil! 👎
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 87
Joined: 2024-11-03, 02:45 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *xxxdo1 »

2Fla$her
Yes, this is the first time I see JavaScript used in TC buttons
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *Fla$her »

2xxxdo1
Well, if you search, you can find my other buttons (1, 2, 3, 4). ;)
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *petermad »

2hi5
I like the script method, it is easier and more convenient.
Well adding these should not be so inconvenient:

wincmd.ini:

Code: Select all

[rename]
Add current date_name=[N]_[T2][D]-[M]-[Y]_[h]·[m]·[s]
Add current date_ext=[E]
usercmd.ini:

Code: Select all

[em_adddCurrentDate]
cmd=MULTIRENAME==Add current date
menu=Add current date and time to item name(s)
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *Fla$her »

Well adding these should not be so inconvenient:
There are two points here: slower and there is no check for '_'.
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *petermad »

Just curious - Which javascript / ECMAScript version does mshta support?
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *Fla$her »

mshta is built around Trident's built-in JScript engine.
It mainly supports ECMAScript 3 with very limited features from ECMAScript 5.
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters

Post by *petermad »

2Fla$her Thanks :-)
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply