Does TC have Date Parameter

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
ehab
Senior Member
Senior Member
Posts: 271
Joined: 2007-10-29, 07:41 UTC
Location: Libya

Does TC have Date Parameter

Post by *ehab »

hi

i would like to launch a program and send it current date in YYYY-MM-DD format does TC have parameters to get current and format date.

just like %P %N %T..

is there %YYYY-%MM-%DD

any help appreicated?

thanks
ehab
Last edited by ehab on 2007-11-13, 18:36 UTC, edited 1 time in total.
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3278
Joined: 2003-05-06, 11:46 UTC

Post by *Sir_SiLvA »

no there isnt you can try if %date% works...
if not you have to use a batch.
Hoecker sie sind raus!
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

I miss this feature too. Additionally to the above it could be used
to create new directories containing the actual date, e.g. through a user defined command
(em_MkDirDate, type "NewDir" in the dialog and get "20071113_NewDir" created).

This would be a great enhancement, IMO - Support+.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

Found some solutions (thanks for the idea, Sir SiLvA)...

All depend on the regional date format settings, I assume %date% to be something like "Tue 13.11.2007" like it is here.
You can find out yours by typing "echo %date%" on the command line.

I hope I have included all possible separator characters (delims=),
maybe the order of %g%f%e has to be adjusted to your local needs, e.g. %e-%f-%g.

Note: The "Command: " for TC below is always a single line - if there is a line break while displaying in your browser, the second line has to be appended to the first, separated by a space.


The simple one, if only the date has to be passed or spaces between the date and possible additional parameters are OK, then TC is enough:
e.g. in the starter menu:

Code: Select all

Command: %comspec% /c for /F "usebackq tokens=2,3,4 delims=.,;:-/\ " %e in (`echo %date%`) do YourCommandHere.exe %g%f%e
Parameters: ?
Parameter field can be left empty, if only the date has to be submitted.


The more complete one, if you'd like to achieve something like "20071113_new dir name" this can be done with an external batch.
E.g. in the starter menu:

Code: Select all

Command: %comspec% /c for /F "usebackq tokens=2,3,4 delims=.,;:-/\ " %e in (`echo %date%`) do mdconcat.cmd %g%f%e_
Parameters: ?
...with mdconcat.cmd containing the following (substitue "md" with the program name you like):

Code: Select all

   : rem MdConcat.cmd  (W) StatusQuo 2007
   : rem concat given parameters (maybe each in quotes)
   : rem to a string; no space between 1st + 2nd parameter
   : rem
   : rem Example:
   : rem    MdConcat "20071113_" NewDir 01
   : rem will make a dir "20071113_NewDir 01"
   @echo off %debug% >nul
   if "%~1"=="" goto ex
   setlocal
   set mdtmp=%~1%~2
:Loop
   if "%~3"=="" goto EndLoop
   set mdtmp=%mdtmp% %~3
   shift
   goto Loop

:EndLoop
   md "%mdtmp%"
   
:ce
:ex
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

i would like to launch a program and send it current date in YYYY-MM-DD format
http://www.ghisler.ch/wiki/index.php/AutoHotkey

LaunchAndSendDateAsParameter.ahk:
Run, X:\path\to\blabla.exe %A_YYYY%-%A_MM%-%A_DD%

Icfu
This account is for sale
User avatar
ehab
Senior Member
Senior Member
Posts: 271
Joined: 2007-10-29, 07:41 UTC
Location: Libya

Post by *ehab »

Thanks to all

and specially StatusQuo , i have different short date format so i had to change tokens=2,3,4 a bit but all is well.

is it too much to ask if you can explain or provide some links about " The simple one " , for example HOw does the %g%f%e work and what are they for.

Thanks again. appreciated : )
#181344 Personal licence
User avatar
ehab
Senior Member
Senior Member
Posts: 271
Joined: 2007-10-29, 07:41 UTC
Location: Libya

Post by *ehab »

@ icfu

i seen you use AutoHotKey in many places, so looks like i may need it one day. tnxs
#181344 Personal licence
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

For NT systems:


C:\> copy nul %Date:~-4,4%-%Date:~-7,2%-%Date:~-10,2%.txt
gives "2007-11-13.txt"

Code: Select all

[em_CreateNewFile]
cmd=%comspec% /c copy nul
Param=?_%%Date:~-4,4%%-%%Date:~-7,2%%-%%Date:~-10,2%%.txt

C:\>md nul Download_%Date:~-2,2%%Date:~-7,2%
gives new folder "Download_0711"

Code: Select all

[em_MD_Download0711]
cmd=%comspec% /c md nul
Param=Download_%%Date:~-2,2%%%%Date:~-7,2%%
You can execute this user commands with command line alias too:
icfu wrote: Aliases are meant to be typed(!) in command line, as an alternative to a
button, a shortcut, a starter or menu entry. So, if you want to create a
directory NewDir, just type "mdd NewDir" in command line and it will work.

Code: Select all

[Alias]
mdd=em_MkDirDate

[em_MkDirDate]
cmd=%comspec% /c
param=md "%%date:~-4,4%%%%date:~-7,2%%%%date:~-10,2%%_%A"
Put an alias placeholder where you want to have
an alternative text every time. See the %A in the code above.

Then you can use:
=> mdd NewDir

to get an new dir with current date and an flexible part at place of the %A



If you need a shortcut: Assign Ctrl+Shift+F7 to em_MkDirDate in Configuration -> Misc, or edit INI:

Code: Select all

[Shortcuts]
CS+F7=em_MkDirDate
Edit the user-defined command and
prepend a question mark in parameters field
to have a dialog box open whenever you press the shortcut:

Code: Select all

param=?md "%%date:~-4,4%%%%date:~-7,2%%%%date:~-10,2%%_%A" 




http://www.ghisler.ch/board/viewtopic.php?t=16094

Posted: Wed Jun 27, 2007 05:22 Post subject: Reply with quote
2KucingLapar
Try to use one of these tools:
http://en.totalcmd.pl/download/add/add/Newfile (Big Dialog and Templates)
http://en.totalcmd.pl/download/add/Add/New_File (Small Editbox, Folder or File)
http://en.totalcmd.pl/download/add/add/1_Click_New_File
_________________
DJK
Totally addicted to Total Commander

http://en.totalcmd.pl/download/add/Add/New_File

Run NewFile.exe and write file folder name in dialog box.
If you confirm with Return key - You will have a directory.
With Ctrl+Return - an empty file.To cancel - press Esc
Default name is current date, but you can change it.
Simply run NewFile.exe with new format string as a parameter


%Commander_Path%\Plugins\NewFiles101\NewFile.exe New_%Y-%m-%d.txt
%Commander_Path%\Plugins\NewFiles101\NewFile.exe NewDir_%Y-%m-%d-%H%M%S
Last edited by Stefan2 on 2007-11-14, 07:15 UTC, edited 2 times in total.
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2ehab
for example HOw does the %g%f%e work and what are they for.
You can get a complete syntax description with

Code: Select all

FOR /?
on the command line.

How my "simple" version works:
%comspec% /c for /F "usebackq tokens=2,3,4 delims=.,;:-/\ " %e in (`echo %date%`) do YourCommandHere.exe %g%f%e
%comspec% /c for: start command line, execute FOR command, then exit command line.
usebackq: prevent confusion if double quotes appear in the line
tokens=2,3,4: what parts of the line are used (# 2, 3, 4 here)
delims=.,;:-/\ : which characters in the line separate the parts from each other
in (`echo %date%`): use the output of the echo command
%g%f%e: %e is used as the variable for the first used part/token (which is #2 as specified before: tokens=2,3,4); %f is token 3, %g is token 4.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2Stefan2
C:\>md nul Download_%Date:~-2,2%%Date:~-7,2%
Wow, great - this is even simpler.
I assume the "nul" above is a copy&paste error, but apart from that this works well, too.
Thanks a lot!
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

FYI: Syntax is explained here:
=> set /?
e.g. through a user defined command
(em_MkDirDate, type "NewDir" in the dialog and get "20071113_NewDir" created
Can be done like that (Stefan2 has forgotten %A above...):

Code: Select all

[Alias]
mdd=em_MkDirDate

[em_MkDirDate]
cmd=%comspec% /c
param=md "%%date:~-4,4%%%%date:~-7,2%%%%date:~-10,2%%_%A"
=> mdd NewDir

Icfu
This account is for sale
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2icfu
Thanks for the additional info, now it's working as alias, too.

The drawback of user-defined commands seems to be,
that I can't manage to assign a keyboard shortcut to this (having a dialog box for parameters).
(Ctrl-Shift-F7 would be nice, with Ctrl-Alt-F7 I could live, too - the way I use the batch solution now.)

What I tried:
The starter menu does not allow the alias (mdd not found),
nor the user-defined command (em_MkDirDate: no parameter input possible).
Neither does Configuration->Misc.,
the same on the button bar (additionally no shortcuts can be defined here). :?

Does it really need AHK to get a keyboard shortcut for a user-defined command, or have I just overlooked this option??
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Aliases are meant to be typed(!) in command line, as an alternative to a button, a shortcut, a starter or menu entry. So, if you want to create a directory NewDir, just type "mdd NewDir" in command line and it will work.

If you need a shortcut: Assign Ctrl+Shift+F7 to em_MkDirDate in Configuration -> Misc, or edit INI:

Code: Select all

[Shortcuts]
CS+F7=em_MkDirDate
Edit the user-defined command and prepend a question mark in parameters field to have a dialog box open whenever you press the shortcut:
param=?md "%%date:~-4,4%%%%date:~-7,2%%%%date:~-10,2%%_%A"

It would be much better if TC would only request the relevant parameter %A in this case of course but until now %A only has an effect in command line. Should be requested...

Icfu
This account is for sale
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2icfu
type "mdd NewDir" in command line and it will work.
Yes, it does.
Edit the user-defined command and prepend a question mark in parameters field
Aah, right, the question mark. This was the overlooked part, thanks again.

Now I have 4 different ways of creating 20071113_NewDir without typing the date to choose from -
two with batch (only showing the "NewDir" part in the dialog) and two without external files.
Time will show which one will survive the longest. :)
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
esunar
New Member
New Member
Posts: 1
Joined: 2008-01-14, 12:03 UTC
Location: Turkey

Post by *esunar »

icfu wrote:FYI: Syntax is explained here:
=> set /?
e.g. through a user defined command
(em_MkDirDate, type "NewDir" in the dialog and get "20071113_NewDir" created
Can be done like that (Stefan2 has forgotten %A above...):

Code: Select all

[Alias]
mdd=em_MkDirDate

[em_MkDirDate]
cmd=%comspec% /c
param=md "%%date:~-4,4%%%%date:~-7,2%%%%date:~-10,2%%_%A"
=> mdd NewDir

Icfu
what if I want to use this with cd command

cd d:\downloads\%Date:~-7,2%\%Date:~-10,2%

i tried this but it did not worked.
Post Reply