Hotlist/Buttonbar/Menu -> Jump to newest folder in subfol

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
seb-
Senior Member
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

Post by *seb- »

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
seb-
Senior Member
Senior Member
Posts: 276
Joined: 2011-11-15, 06:14 UTC
Location: DE\BN - only part time TC user after switching to Linux ;)

Post by *seb- »

Oh i'm sorry... i must have clicked the wrong forum :-(

This should have been posted to TC English forum.

please move. thx.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

[mod]Moved to the English forum.

Hacker (Moderator)[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
nsp
Power Member
Power Member
Posts: 1956
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su

Post by *nsp »

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 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.
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%
If you want to go to latest folder from anywhere, you can modify to such GotoLastFolder.cmd

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%
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.

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.
seb-
Senior Member
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

Post by *seb- »

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.
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.

So junctions are apparently no option, as cool as they seem to be...
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.

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%
If you want to go to latest folder from anywhere, you can modify to such GotoLastFolder.cmd

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%
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.

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.
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?

Would you describe a bit more detailed?

Thanks a lot already!

br seb
User avatar
nsp
Power Member
Power Member
Posts: 1956
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su

Post by *nsp »

nsp wrote:...
If you want to go to latest folder from anywhere, you can modify to such GotoLastFolder.cmd

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%
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.

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.
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?
First file is a sample i use myself. (I basically use if from command line)
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.
seb- wrote: Would you describe a bit more detailed?
- Technical hints :
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.
seb-
Senior Member
Senior Member
Posts: 276
Joined: 2011-11-15, 06:14 UTC
Location: DE\BN - only part time TC user after switching to Linux ;)

Post by *seb- »

Hi!

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'
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
seb-
Senior Member
Senior Member
Posts: 276
Joined: 2011-11-15, 06:14 UTC
Location: DE\BN - only part time TC user after switching to Linux ;)

Post by *seb- »

Got it...

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
Will print Dirs also with whitespaces...

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%

works fine :)

THANKS SO MUCH for pointing me to the right direction!
seb
User avatar
white
Power Member
Power Member
Posts: 6017
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

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
seb-
Senior Member
Senior Member
Posts: 276
Joined: 2011-11-15, 06:14 UTC
Location: DE\BN - only part time TC user after switching to Linux ;)

Post by *seb- »

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
That might be even more interesting as it would work without the .cmd file.

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 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
User avatar
nsp
Power Member
Power Member
Posts: 1956
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

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
If your folders are kept in sync and already created at the same place :
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.
seb-
Senior Member
Senior Member
Posts: 276
Joined: 2011-11-15, 06:14 UTC
Location: DE\BN - only part time TC user after switching to Linux ;)

Post by *seb- »

It works very well with this setup i did yesterday evening

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 
Call from TC Hotlist

Code: Select all

%commander_path%\gotoLastFolder2.cmd  P:\Full\Base\Dir\Path  _BLANK_ Cycle*
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 :-)
User avatar
white
Power Member
Power Member
Posts: 6017
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

seb- wrote:... because you can not simply CD to E:\...\... etc. you have to activate the drive first and then CD to the directory...
That's why they invented the parameter /D. 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
seb-
Senior Member
Senior Member
Posts: 276
Joined: 2011-11-15, 06:14 UTC
Location: DE\BN - only part time TC user after switching to Linux ;)

Post by *seb- »

white 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
Great... That works without any cmd file :-)

Thanks!
User avatar
nsp
Power Member
Power Member
Posts: 1956
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

seb- wrote:
white 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
Great... That works without any cmd file :-)

Thanks!
It is true, but sometime a batch file is easier to find, you can comment it to reuse, adapt ..
You can even put it on your desktop to launch TC with all folder setup at once !
Post Reply