Hotlist/Buttonbar/Menu -> Jump to newest folder in subfol
Moderators: Hacker, petermad, Stefan2, white
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
Hotlist/Buttonbar/Menu -> Jump to newest folder in subfol
Hi guys,
luxury problem....
i keep handling files in a structure like
d:\basedir\project\cycle_1
d:\basedir\project\cycle_2
d:\basedir\project\cycle_3
basedir is synced across multiple places....
is there an easy way to go to the last folder? Folders are added every second week and i use this structure on 2 computers for 3 places.
If i would reference to the latest folder manually this would mean to change 6 places.
Is there a way to use a script to find out the last folder and change-dir to this folder?
thanks+br
sebastian
luxury problem....
i keep handling files in a structure like
d:\basedir\project\cycle_1
d:\basedir\project\cycle_2
d:\basedir\project\cycle_3
basedir is synced across multiple places....
is there an easy way to go to the last folder? Folders are added every second week and i use this structure on 2 computers for 3 places.
If i would reference to the latest folder manually this would mean to change 6 places.
Is there a way to use a script to find out the last folder and change-dir to this folder?
thanks+br
sebastian
Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su
if you use ntfs, you should create at same time you create new cycle a junction called latest_cycle and use a button in TC that switch to this folder.seb- wrote:Hi guys,
luxury problem....
i keep handling files in a structure like
d:\basedir\project\cycle_1
d:\basedir\project\cycle_2
d:\basedir\project\cycle_3
basedir is synced across multiple places....
is there an easy way to go to the last folder? Folders are added every second week and i use this structure on 2 computers for 3 places.
If i would reference to the latest folder manually this would mean to change 6 places.
Is there a way to use a script to find out the last folder and change-dir to this folder?
thanks+br
sebastian
If you do not use ntfs, you can probably create a batch file that change to this folder using some tool like nircmd.
This is a script i use to go to specific folder from command line.
Code: Select all
@echo off
set _mFolder=%CD%
setlocal ENABLEEXTENSIONS
if not exist "%1" goto DOTC
set _mFolder="%~dp1"
:: LAUNCH or Show Total commander
:DOTC
nircmdc exec show "C:\tools\totalcmd\TOTALCMD.EXE" /O /S /L=%_mFolder%
Code: Select all
@echo off
for /F %%f in ('dir /A:D /O:D /B'/T:C ) do set _mFolder="%CD%\%%f"
"%commander_path%\TOTALCMD.EXE" /O /S /L=%_mFolder%
You just have to create this script anywhere an assign it to a button and verify that startup folder is set to empty or %P.
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su
That worked great on my win7 machine, but not on my USB Pendrive which is fat32 (i could convert that...) and last but most limited in change: my office computer, where i still have just user privileges.nsp wrote: if you use ntfs, you should create at same time you create new cycle a junction called latest_cycle and use a button in TC that switch to this folder.
So junctions are apparently no option, as cool as they seem to be...
That sounds interesting and nircmd (i already use a lot of nirsoft tools which is why i trust it) seems to be portable and not require any admin privileges (so i can use it on my office pc).nsp wrote: If you do not use ntfs, you can probably create a batch file that change to this folder using some tool like nircmd.
This is a script i use to go to specific folder from command line.If you want to go to latest folder from anywhere, you can modify to such GotoLastFolder.cmdCode: Select all
@echo off set _mFolder=%CD% setlocal ENABLEEXTENSIONS if not exist "%1" goto DOTC set _mFolder="%~dp1" :: LAUNCH or Show Total commander :DOTC nircmdc exec show "C:\tools\totalcmd\TOTALCMD.EXE" /O /S /L=%_mFolder%
Depending to your os language you should modify the dir command with /A: parameter to only select folder /O: order on date /T: dateTime Creation.Code: Select all
@echo off for /F %%f in ('dir /A:D /O:D /B'/T:C ) do set _mFolder="%CD%\%%f" "%commander_path%\TOTALCMD.EXE" /O /S /L=%_mFolder%
You just have to create this script anywhere an assign it to a button and verify that startup folder is set to empty or %P.
However i do not quite understand to get to the setup you describe.
Where do both files (in your quotes) go and how do i name them?
Would you describe a bit more detailed?
Thanks a lot already!
br seb
Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su
nsp wrote:...
If you want to go to latest folder from anywhere, you can modify to such GotoLastFolder.cmdDepending to your os language you should modify the dir command with /A: parameter to only select folder /O: order on date /T: dateTime Creation.Code: Select all
@echo off for /F %%f in ('dir /A:D /O:D /B /T:C' ) do set _mFolder="%CD%\%%f" "%commander_path%\TOTALCMD.EXE" /O /S /L=%_mFolder%
You just have to create this script anywhere an assign it to a button and verify that startup folder is set to empty or %P.
First file is a sample i use myself. (I basically use if from command line)seb- wrote:
That sounds interesting and nircmd (i already use a lot of nirsoft tools which is why i trust it) seems to be portable and not require any admin privileges (so i can use it on my office pc).
However i do not quite understand to get to the setup you describe.
Where do both files (in your quotes) go and how do i name them?
Second file is something that fit best your requirement. You can name it GotoLastFolder.cmd and put it everywhere you have write access. I personnaly have a script folder inside total commander installation falder called scripts.
- Technical hints :seb- wrote: Would you describe a bit more detailed?
The script for/do line loop over a folder list generated and sorted by creation date/time using dir command and set the _mFolder variable. As the list is ordered, only the last one is kept.
Last line call TC and tell to launch or set the current panel to the folder pointed by _mFolder variable.
-- What to adapt :
M$ have localized the dir command, so depending on your os language the switch parameters i used for /A: /O: and /T:. You have to addapt the dir command inside quote to list only folder ordered by creation date. (If you only whant to target cycle_* folder add it also).
If you use TC 64bit you also have to mofify totalcmd.exe to 64bit executable.
--- Once done What to do for each TC installation :
As said create your script and put it in an accessible folder, drag and drop the script to the buton bar and edit to have %P or empty as starting path and choose a nice icon.
If you want to use %commnader_path%\scripts, as folder base it is up to you !
---- How to use
If you are on a project folder (or anything else) click on the buton and TC will automatically jump to the lastest created folder.
Ex you have
Code: Select all
Project
cycle_1 01/01/2012
..
cycle_13 24/06/20012
if you click on the button, TC will directly jump to cycle_13 subfolder.
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
Hi!
Thanks for the further info.
I think i'm almost where i want to be...
my .cmd currently looks like this
I added the "cycle*" to the dir command to only get the folders starting with cycle.
Next Problem: SPACE
the folders are named
Cycle 1
Cycle 2
Cycle x
Apparently i did not clearly mention this in the first post, sorry.
Now the output of the Script is
Cycle
Cycle
Cycle
because it can not cope with the Whitespace character...
I tried putting quotes around some stuff without knowing wether it helps and i couldnt find a way to achieve proper output...
Any suggestion?
Thanks so far already!
br
seb
Thanks for the further info.
I think i'm almost where i want to be...
my .cmd currently looks like this
Code: Select all
for /F %%f in ('dir Cycle* /A:D /O:D /B /T:C') do echo '%%f'
Next Problem: SPACE
the folders are named
Cycle 1
Cycle 2
Cycle x
Apparently i did not clearly mention this in the first post, sorry.
Now the output of the Script is
Cycle
Cycle
Cycle
because it can not cope with the Whitespace character...
I tried putting quotes around some stuff without knowing wether it helps and i couldnt find a way to achieve proper output...
Any suggestion?
Thanks so far already!
br
seb
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
Got it...
when using /F the FOR takes only the first token of a line.
With "delims=" you can turn this off....
Will print Dirs also with whitespaces...
NOw
works fine 
THANKS SO MUCH for pointing me to the right direction!
seb
when using /F the FOR takes only the first token of a line.
With "delims=" you can turn this off....
Code: Select all
@echo off
for /F "delims=" %%f in ('dir Sprint* /A:D /O:D /B /T:C') do echo %%~f
NOw
Code: Select all
@echo off
for /F "delims=" %%f in ('dir Sprint* /A:D /O:D /B /T:C') do set _mFolder="%CD%\%%f"
"%commander_path%\TOTALCMD.EXE" /O /S /L=%_mFolder%

THANKS SO MUCH for pointing me to the right direction!
seb
You can also assign the following line to a button, hotkey, alias, directory hotlist entry, menu entry.
Code: Select all
%comspec% /q /c for /F "delims=" %f in ('dir Sprint* /A:D /O:-D /B /T:C') do "%commander_exe%" /O /S /L="%~ff" & exit
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
That might be even more interesting as it would work without the .cmd file.white wrote:You can also assign the following line to a button, hotkey, alias, directory hotlist entry, menu entry.
Code: Select all
%comspec% /q /c for /F "delims=" %f in ('dir Sprint* /A:D /O:-D /B /T:C') do "%commander_exe%" /O /S /L="%~ff" & exit
I had to work around another issue after i found a working solution yesterday.
Because i have this folder structure at 3 places (Local, USB Drive, Network drive) which i all keep in sync (yes, thats very tedious, but TC offers some possibilities to save clicks

I'll try with the one line you provided. THanks for your participation

br
seb
If your folders are kept in sync and already created at the same place :seb- wrote: Because i have this folder structure at 3 places (Local, USB Drive, Network drive) which i all keep in sync (yes, thats very tedious, but TC offers some possibilities to save clicks), i wanted to have one script file that supports 3 different drives, because you can not simply CD to E:\...\... etc. you have to activate the drive first and then CD to the directory...
I'll try with the one line you provided. THanks for your participation
br
seb
D:\AAA\BBB\project\Cycle 12
U:\AAA\BBB\project\Cycle 12
N:\AAA\BBB\project\Cycle 12
inside the script, you can replace drive letter of the Local drive with the usb drive and network drive.
Code: Select all
rem %1 is the usb drive as U:
rem %2 is network drive or unc path
for /f "delims=: tokens=2" %P in ( %_mFolder% ) do set _onlyPath=%P
set _usbPath="%1%_onlyPath%"
set _netPath="%2%_onlyPath%"
After you can: give a look to TC command line
- call TC to go on local drive Source panel
- call TC to go on usb drive target side with new panel
- call TC to go on net drive target side with new panel
It is up to you to adapt the script.....
inside TC, you can add a ? and default drive values in the parameter part to edit each time you launch your script from TC.
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
It works very well with this setup i did yesterday evening
Call from TC Hotlist
note the _BLANK_ is really a whitespace to seperate the Path of the basedir and the Folder Prefix (cycle*)
Works great for me...
i just need to configure the base dir for each button once and then.. no problems
Code: Select all
@echo off
REM change drive first... ~d extracts drive from %1
%~d1
REM change to directory first
cd "%1"
for /F "delims=" %%f in ('dir %2 /A:D /O:D /B /T:C') do set _mFolder="%CD%\%%f"
echo %1
echo %2
REM set _mFolder="%CD%\%%f"
"%commander_path%\TOTALCMD.EXE" /O /S /L=%_mFolder%
REM pause
Code: Select all
%commander_path%\gotoLastFolder2.cmd P:\Full\Base\Dir\Path _BLANK_ Cycle*
Works great for me...
i just need to configure the base dir for each button once and then.. no problems

That's why they invented the parameter /D. Try:seb- wrote:... because you can not simply CD to E:\...\... etc. you have to activate the drive first and then CD to the directory...
Code: Select all
%comspec% /q /c cd /d "P:\Full\Base\Dir\Path" & for /F "delims=" %f in ('dir Cycle* /A:D /O:-D /B /T:C') do "%commander_exe%" /O /S /L="%~ff" & exit
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
Great... That works without any cmd filewhite wrote: Try:
Code: Select all
%comspec% /q /c cd /d "P:\Full\Base\Dir\Path" & for /F "delims=" %f in ('dir Cycle* /A:D /O:-D /B /T:C') do "%commander_exe%" /O /S /L="%~ff" & exit

Thanks!
It is true, but sometime a batch file is easier to find, you can comment it to reuse, adapt ..seb- wrote:Great... That works without any cmd filewhite wrote: Try:
Code: Select all
%comspec% /q /c cd /d "P:\Full\Base\Dir\Path" & for /F "delims=" %f in ('dir Cycle* /A:D /O:-D /B /T:C') do "%commander_exe%" /O /S /L="%~ff" & exit
Thanks!
You can even put it on your desktop to launch TC with all folder setup at once !