| View previous topic :: View next topic |
| Author |
Message |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Tue Jul 03, 2012 7:04 am Post subject: 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 |
|
| Back to top |
|
 |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Tue Jul 03, 2012 7:15 am Post subject: |
|
|
Oh i'm sorry... i must have clicked the wrong forum
This should have been posted to TC English forum.
please move. thx. |
|
| Back to top |
|
 |
Hacker Moderator


Joined: 06 Feb 2003 Posts: 9108 Location: Bratislava, Slovakia
|
Posted: Tue Jul 03, 2012 7:19 am Post subject: |
|
|
| 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 |
|
 |
nsp Power Member


Joined: 04 Dec 2005 Posts: 715 Location: Lyon (FRANCE)
|
Posted: Tue Jul 03, 2012 9:46 am Post subject: Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su |
|
|
| 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 |
|
 |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Wed Jul 04, 2012 12:23 am Post subject: Re: Hotlist/Buttonbar/Menu -> Jump to newest folder in su |
|
|
| 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 |
|
 |
nsp Power Member


Joined: 04 Dec 2005 Posts: 715 Location: Lyon (FRANCE)
|
Posted: Wed Jul 04, 2012 5:47 am Post subject: 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.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 |
|
 |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Wed Jul 04, 2012 7:29 am Post subject: |
|
|
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 |
|
 |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Wed Jul 04, 2012 7:52 am Post subject: |
|
|
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
THANKS SO MUCH for pointing me to the right direction!
seb |
|
| Back to top |
|
 |
white Power Member


Joined: 19 Nov 2003 Posts: 1304 Location: Netherlands
|
Posted: Wed Jul 04, 2012 11:06 am Post subject: |
|
|
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 |
|
 |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Wed Jul 04, 2012 11:34 pm Post subject: |
|
|
| 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 ), 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 |
|
| Back to top |
|
 |
nsp Power Member


Joined: 04 Dec 2005 Posts: 715 Location: Lyon (FRANCE)
|
Posted: Thu Jul 05, 2012 2:38 am Post subject: |
|
|
| 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: | 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 |
|
 |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Thu Jul 05, 2012 3:14 am Post subject: |
|
|
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  |
|
| Back to top |
|
 |
white Power Member


Joined: 19 Nov 2003 Posts: 1304 Location: Netherlands
|
Posted: Thu Jul 05, 2012 4:07 pm Post subject: |
|
|
| 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 |
|
 |
seb- Member

Joined: 15 Nov 2011 Posts: 106 Location: DE\BN
|
Posted: Fri Jul 06, 2012 3:57 am Post subject: |
|
|
| 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
Thanks! |
|
| Back to top |
|
 |
nsp Power Member


Joined: 04 Dec 2005 Posts: 715 Location: Lyon (FRANCE)
|
Posted: Fri Jul 06, 2012 8:09 am Post subject: |
|
|
| 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
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 |
|
 |
|