This forum uses cookies. Click X button to hide this message. What is stored? / Privacy
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Toolbar button to switch path by current date

 
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) Printable version
View previous topic :: View next topic  
Author Message
jenka1980
New Member
New Member


Joined: 16 May 2018
Posts: 1

PostPosted: Wed May 16, 2018 2:30 am    Post subject: Toolbar button to switch path by current date Reply with quote

Hello,

I have a log directories which created by dates e.g. "D:\Logs\0516" (for 16 in May).

I tried to create a button to switch source tab to this log directory.
First I used the CD command like so:
Code:
CD D:\Logs\%date:~4,2%%date:~7,2%

But this only opens the "D:\Log" directory.

Then I tried using this command:
Code:
%COMMANDER_PATH%\TOTALCMD64.exe /O /L="D:\Logs\%date:~4,2%%date:~7,2%"

This one also didn't help as it switches the left tab to the "D:\Log" directory.
Executing the same command from windows command prompt opens the full path in left tab "D:\Log\0516"

May be I'm doing something wrong and there is an other way to achieve my goal.
Hope you could help my
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 35424
Location: Switzerland

PostPosted: Wed May 16, 2018 4:33 am    Post subject: Reply with quote

The %date:~4,2%%date:~7,2% substitution is done by cmd.exe, not by Windows. Try calling cmd.exe calling totalcmd64.exe.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Stefan2
Power Member
Power Member


Joined: 13 Sep 2007
Posts: 1871
Location: Europa

PostPosted: Wed May 16, 2018 5:21 am    Post subject: VBScript: SendMessage (switch to defined folder plus Date) Reply with quote

I don't get that to work and my lunch break is over:

SET myDate=0516 && setLocal EnableDelayedExpansion && %%Commander_EXE%% /O /L="c:\Temp\TC\LOGS\!myDate!"

any help?





Instead I would use a VBScript:
Code:
'// TotalCommander VBScript to switch current path
'// Found at https://ghisler.ch/board/viewtopic.php?p=341233#341233
'// - - - To use create an button like:
'// - - -    Command = "%COMMANDER_PATH%\TOOLs\CMDs\Switch to folder current date.VBS"
'// - - -    Parameters =
'// - - -    Start path =
'// - - -    Icon = C:\windows\System32\WScript.exe,2
'// - - -    Tool tip = Switch to LOGS folder of current date

'//-------------------------------------------------------- USER SETTINGS
v_BasePath    = "c:\Temp\TC\LOGS\"
v_Month    = Right("0"&Month(Now),2)
v_Day       = Right("0"&Day(Now),2)
v_PATH      = v_BasePath  & "\" & v_Month & v_Day

'//-------------------------------------------------------- THE CODE
'//Switch to other (inactive) panel
'cm_FocusTrg=4006;Focus on target file list
SendMessage "Total Commander",1075,4006,0

'// SET FOCUS to address field
'cm_EditPath=2912;Edit path field above file list
SendMessage "Total Commander",1075,2912,0

'// SEND KEYs
'https://ss64.com/vb/sendkeys.html
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys v_PATH   & "{ENTER}"

'//-------------------------------------------------------- HELPER function
'VBScript SendMessage 'http://demon.tw/copy-paste/vbs-sendmessage.html 'BY Coo_boi
Function SendMessage(lpWinTitle,wMsg,wParam,lParam)
   Dim WordApp,ShApp,colTask,oTask
   Set WordApp=CreateObject("Word.Application")
   Set colTask=wordapp.Tasks
   SendMessage=False
   For Each oTask In colTask
      If oTask.Visible And InStr(oTask.Name,lpWinTitle) Then
         oTask.SendWindowMessage wMsg,wParam,lParam
         SendMessage=True
         Exit For
      End If
   Next
   WordApp.Quit
   Set WordApp=Nothing
End Function
'//--------------------------------------------------------






 
_________________
Begegnen sich zwei Erden, sagt die Eine zur Anderen: "Mir geht's echt schlecht. Ich habe Homo sapiens!"
Back to top
View user's profile Send private message
Horst.Epp
Power Member
Power Member


Joined: 06 Feb 2003
Posts: 2859
Location: Germany

PostPosted: Wed May 16, 2018 5:42 am    Post subject: Reply with quote

I use Nirsofts Nircmd for such function.
http://www.nirsoft.net/utils/nircmd.html

For your case make a button with the following em_command:

[em_CDToLog]
cmd=c:\tools\NirSoft\x64\nircmd.exe exec show %COMMANDER_EXE% /O /L=D:\logs\~$currdate.MMdd$

You have to adjust the path of your nircmd.exe of course.
_________________
Windows 10 x64 Version 1803
April 2018 Update (OS Build 17134.48)
TC 9.20b3 x64 and x86
Back to top
View user's profile Send private message
Stefan2
Power Member
Power Member


Joined: 13 Sep 2007
Posts: 1871
Location: Europa

PostPosted: Wed May 16, 2018 6:17 am    Post subject: NirCmd switch to folder of current date Reply with quote

Horst.Epp wrote:
I use Nirsofts Nircmd


nircmd in combination with TCs command line options is the best way, :thumbsup:





 
_________________
Begegnen sich zwei Erden, sagt die Eine zur Anderen: "Mir geht's echt schlecht. Ich habe Homo sapiens!"
Back to top
View user's profile Send private message
petermad
Power Member
Power Member


Joined: 05 Feb 2003
Posts: 7653
Location: Valsted, Denmark

PostPosted: Wed May 16, 2018 9:34 am    Post subject: Reply with quote

This button should do it:
Code:
TOTALCMD#BAR#DATA
%COMSPEC% /C %COMMANDER_EXE% /O /S /L="D:\Logs\%date:~4,2%%date:~7,2%"

%COMMANDER_EXE%,6
Open D:\Logs\date


-1

Quote:
To make the button:
1. Mark the green text above (including TOTALCMD#BAR#DATA in the first line and -1 in the last line).
2. Copy it to the ClipBoard (Ctri+C).
3. Right click on TC's buttonbar and choose "Paste".


Note - for other users:
~4,2 and ~7,2 has to match the current locale - Under Danish Windows it would for example be ~0,2 and ~3,2 to match 1605 (sixteenth of may). Type: DATE in a command prompt to see the format on your system.
_________________
#524
Danish Total Commander Translator
TC 9.12 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 64bit. TC 2.91b2 on Android 6.0

Get Extended Total Commander Menus
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Horst.Epp
Power Member
Power Member


Joined: 06 Feb 2003
Posts: 2859
Location: Germany

PostPosted: Wed May 16, 2018 10:00 am    Post subject: Reply with quote

petermad wrote:
This button should do it:
Code:
TOTALCMD#BAR#DATA
%COMSPEC% /C %COMMANDER_EXE% /O /S /L="D:\Logs\%date:~4,2%%date:~7,2%"

%COMMANDER_EXE%,6
Open D:\Logs\date


-1

Quote:
To make the button:
1. Mark the green text above (including TOTALCMD#BAR#DATA in the first line and -1 in the last line).
2. Copy it to the ClipBoard (Ctri+C).
3. Right click on TC's buttonbar and choose "Paste".


Note - for other users:
~4,2 and ~7,2 has to match the current locale - Under Danish Windows it would for example be ~0,2 and ~3,2 to match 1605 (sixteenth of may). Type: DATE in a command prompt to see the format on your system.

My date format shows 16.05.2018 for today (German Locale)
Therefore changed your button to %date:~3,2%%date:~0,2%
But I prefer the Nircmd solution which works independent of any locale
and also doesn't show a cmd window while executing
_________________
Windows 10 x64 Version 1803
April 2018 Update (OS Build 17134.48)
TC 9.20b3 x64 and x86
Back to top
View user's profile Send private message
petermad
Power Member
Power Member


Joined: 05 Feb 2003
Posts: 7653
Location: Valsted, Denmark

PostPosted: Wed May 16, 2018 3:57 pm    Post subject: Reply with quote

Quote:
also doesn't show a cmd window while executing

Use this in stead to minimize the cmd window.
Code:
TOTALCMD#BAR#DATA
%COMSPEC% /C %COMMANDER_EXE% /O /S /L="D:\Logs\%date:~4,2%%date:~7,2%"

%COMMANDER_EXE%,6
Open D:\Logs\date

1
-1

_________________
#524
Danish Total Commander Translator
TC 9.12 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 64bit. TC 2.91b2 on Android 6.0

Get Extended Total Commander Menus
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Total Commander (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Imprint/Impressum: This site is maintained by Ghisler Software GmbH
Privacy Policy | Datenschutzerklärung | Politique de Confidentialité

Using phpBB © phpBB Group