Page 1 of 1
Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-25, 08:37 UTC
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?
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-25, 10:41 UTC
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)
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-25, 10:58 UTC
by xxxdo1
2hi5
No, I need to quickly rename a single file for backup purposes, not batch rename
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-25, 11:49 UTC
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.
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-25, 12:37 UTC
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
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-25, 16:08 UTC
by xxxdo1
2
hi5
I like the script method, it is easier and more convenient.
2
Fla$her
Your other methods are also very good, I learned a lot.

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-25, 16:19 UTC
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
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-26, 16:20 UTC
by xxxdo1
2Fla$her
Yes, this is the first time I see JavaScript used in TC buttons
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-26, 18:47 UTC
by Fla$her
2
xxxdo1
Well, if you search, you can find my other buttons (
1,
2,
3,
4).

Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-27, 14:08 UTC
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)
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-27, 15:51 UTC
by Fla$her
Well adding these should not be so inconvenient:
There are two points here: slower and there is no check for '_'.
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-27, 17:57 UTC
by petermad
Just curious - Which javascript / ECMAScript version does mshta support?
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-27, 21:43 UTC
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.
Re: Rename file command, cm_RenameOnly, cm_RenameSingleFile, hope to support parameters
Posted: 2025-01-28, 11:38 UTC
by petermad
2
Fla$her Thanks
