How to create a shortcut to append the date to a file name?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Pocus
Junior Member
Junior Member
Posts: 9
Joined: 2009-08-14, 05:44 UTC

How to create a shortcut to append the date to a file name?

Post by *Pocus »

Is it possible (maybe via Redifine hotkeys) to define a keyboard
shortcut to append the current date to a filename? I need to do
this everyday many times. E.g. file.txt => file_2014-11-07.txt
User avatar
Ovg
Power Member
Power Member
Posts: 755
Joined: 2014-01-06, 16:26 UTC

Post by *Ovg »

2Pocus
Try MRT - Multi Rename Tool (Ctrl - M)
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

Without using batch:

- Create a template in the Multi-Rename Tool with mask

Code: Select all

[N]_[Y]-[M]-[D]
- Save the template (F2) as "Add-Y-M-D"
- Create a button with command:

Code: Select all

MULTIRENAME Add-Y-M-D
With batch:
Save this as "Add_Date.cmd" and put it on a button with parameters

Code: Select all

"%F" "%P" "%T"

Code: Select all

@echo off
setlocal enabledelayedexpansion

rem Button Parameter "%F" "%P" "%T"

set tc_lst=%1
set tc_src=%2
set tc_dst=%3

rem For date format dd.mm.yyyy
set d=%date:~0,2%
set m=%date:~3,2%
set y=%date:~6,4%
set string=_%y%-%m%-%d%

if -%3==- echo First parameter must be filelist path, second and third - source and target path. && pause && goto :EOF
for /F "usebackq delims=" %%I in (%tc_lst%) do (
	
	rem Remove "echo" for production
	echo ren %%~fI %%~nI%string%%%~xI
)
rem Remove "pause" for production
pause
cls
endlocal
Remove the two mentioned commands if it looks right and set "Run minimized" in the button options.

*edit: To use it with a hotkey you have to create an em_ user command which uses the same options as the buttons.
trevor12
Junior Member
Junior Member
Posts: 65
Joined: 2012-12-06, 15:16 UTC
Location: Czech republic

re

Post by *trevor12 »

MULTIRENAME Add-Y-M-D

does not append CURRENT date to my file, that was created in the past
User avatar
Ovg
Power Member
Power Member
Posts: 755
Joined: 2014-01-06, 16:26 UTC

Post by *Ovg »

2trevor12

You are right.

Guru! How add current date to file mask in MRT?
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Can I use the today date (format YMD) in MRT? How?

NOW v0.1 (W) StatusQuo 2008, small VBS-script for TC content plugin SCRIPT.WDX
www.ghisler.ch/board/viewtopic.php?t=18763


 
User avatar
Ovg
Power Member
Power Member
Posts: 755
Joined: 2014-01-06, 16:26 UTC

Post by *Ovg »

2Stefan2
Thank you!

WOW!! It's working!!! :D :D :D
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
trevor12
Junior Member
Junior Member
Posts: 65
Joined: 2012-12-06, 15:16 UTC
Location: Czech republic

re

Post by *trevor12 »

for example for *.log files in current directory this batch file is working:

REN *.LOG "* %Date:/= % %Time::=.%.*log"

maybe somebody would be able use it to create button (command in tray in TC) to rename file on that cursor on panel in TC is located ...

----------
the mode of date (and time) sorting is possible to set in Control panel - Regional settings ...
Post Reply