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 

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

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


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Tue Jul 03, 2012 7:04 am    Post subject: Hotlist/Buttonbar/Menu -> Jump to newest folder in subfol Reply with quote

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
Back to top
View user's profile Send private message
seb-
Member
Member


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Tue Jul 03, 2012 7:15 am    Post subject: Reply with quote

Oh i'm sorry... i must have clicked the wrong forum Sad

This should have been posted to TC English forum.

please move. thx.
Back to top
View user's profile Send private message
Hacker
Moderator
Moderator


Joined: 06 Feb 2003
Posts: 9108
Location: Bratislava, Slovakia

PostPosted: Tue Jul 03, 2012 7:19 am    Post subject: Reply with quote

Moderation:
Moved to the English forum.

Hacker (Moderator)

_________________
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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nsp
Power Member
Power Member


Joined: 04 Dec 2005
Posts: 715
Location: Lyon (FRANCE)

PostPosted: Tue Jul 03, 2012 9:46 am    Post subject: Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su Reply with quote

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:
@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:
@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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
seb-
Member
Member


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Wed Jul 04, 2012 12:23 am    Post subject: Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su Reply with quote

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:
@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:
@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
Back to top
View user's profile Send private message
nsp
Power Member
Power Member


Joined: 04 Dec 2005
Posts: 715
Location: Lyon (FRANCE)

PostPosted: Wed Jul 04, 2012 5:47 am    Post subject: Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su Reply with quote

nsp wrote:
...
If you want to go to latest folder from anywhere, you can modify to such GotoLastFolder.cmd
Code:
@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:
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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
seb-
Member
Member


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Wed Jul 04, 2012 7:29 am    Post subject: Reply with quote

Hi!

Thanks for the further info.

I think i'm almost where i want to be...

my .cmd currently looks like this

Code:

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
Back to top
View user's profile Send private message
seb-
Member
Member


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Wed Jul 04, 2012 7:52 am    Post subject: Reply with quote

Got it...

when using /F the FOR takes only the first token of a line.

With "delims=" you can turn this off....

Code:

@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:

@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 Smile

THANKS SO MUCH for pointing me to the right direction!
seb
Back to top
View user's profile Send private message
white
Power Member
Power Member


Joined: 19 Nov 2003
Posts: 1304
Location: Netherlands

PostPosted: Wed Jul 04, 2012 11:06 am    Post subject: Reply with quote

You can also assign the following line to a button, hotkey, alias, directory hotlist entry, menu entry.

Code:
%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

_________________
#16626 Personal licence
Back to top
View user's profile Send private message Send e-mail
seb-
Member
Member


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Wed Jul 04, 2012 11:34 pm    Post subject: Reply with quote

white wrote:
You can also assign the following line to a button, hotkey, alias, directory hotlist entry, menu entry.

Code:
%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 Wink), 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 Smile


br
seb
Back to top
View user's profile Send private message
nsp
Power Member
Power Member


Joined: 04 Dec 2005
Posts: 715
Location: Lyon (FRANCE)

PostPosted: Thu Jul 05, 2012 2:38 am    Post subject: Reply with quote

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 Wink), 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 Smile


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:
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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
seb-
Member
Member


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Thu Jul 05, 2012 3:14 am    Post subject: Reply with quote

It works very well with this setup i did yesterday evening

Code:

@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:
%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 Smile
Back to top
View user's profile Send private message
white
Power Member
Power Member


Joined: 19 Nov 2003
Posts: 1304
Location: Netherlands

PostPosted: Thu Jul 05, 2012 4:07 pm    Post subject: Reply with quote

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

_________________
#16626 Personal licence
Back to top
View user's profile Send private message Send e-mail
seb-
Member
Member


Joined: 15 Nov 2011
Posts: 106
Location: DE\BN

PostPosted: Fri Jul 06, 2012 3:57 am    Post subject: Reply with quote

white wrote:
Try:

Code:
%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 Smile

Thanks!
Back to top
View user's profile Send private message
nsp
Power Member
Power Member


Joined: 04 Dec 2005
Posts: 715
Location: Lyon (FRANCE)

PostPosted: Fri Jul 06, 2012 8:09 am    Post subject: Reply with quote

seb- wrote:
white wrote:
Try:

Code:
%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 Smile

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 !
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
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


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group