Page 1 of 1

Keyboard shortcut to Jump to Next folder

Posted: 26 Apr 2016 18:06
by DarKHawK
Hi,

Is there any hidden to jump to the next inline folder?

Thanks.

Re: Keyboard shortcut to Jump to Next folder

Posted: 26 Apr 2016 18:29
by highend
You mean from anything that's currently selected (e.g. a file) or in e.g. a manual sorted list from:

afolder
a.txt
bfolder
c.txt

directly from afolder to bfolder?

I'm not aware of something preexisting but you could use a UDC and assign it a keyboard shortcut and use a script:

Code: Select all

    $preMatch = ""; $postMatch = ""; $items = listpane(); $curPos = get("FocusedPos");
    while ($i++ < gettoken($items, "count", "|")) {
        $item = gettoken($items, $i, "|");
        if (exists($item) != 2 ) { continue; }
        if ($i > $curPos) { $postMatch = $item; break; }
        if ($preMatch) { continue; }
        if ($i <= $curPos) { $preMatch = $item; }
    }
    selectitems ($postMatch) ? $postMatch : (($preMatch) ? $preMatch : <curitem>);

Re: Keyboard shortcut to Jump to Next folder

Posted: 26 Apr 2016 20:09
by DarKHawK
Thank you for your reply.

I didn't mean it like that. For that I would use the arrow keys.

I mean if I'm currently in a folder which contains files.
I want to jump directly to the next folder and open it.

mainfolder
subfolder1
subfolder2
subfolder3

If I'm current in subfolder2 viewing those files, I want to jump directly to subfolder3.

Thanks again.

Re: Keyboard shortcut to Jump to Next folder

Posted: 26 Apr 2016 21:22
by highend
This one doesn't contain the logic to jump back to a folder that's above the one you're currently in...

Code: Select all

    $parentFolders = listfolder(regexreplace(<curpath>, "^(.*)(\\.*)", "$1"), , 2);
    $curPos = gettokenindex(<curpath>, $parentFolders, , "");
    $nextFolder = "";
    while ($curPos++ < gettoken($parentFolders, "count", "|")) {
        $item = gettoken($parentFolders, $curPos, "|");
        if (exists($item) == 2 ) { $nextFolder = $item; break; }
    }
    if ($nextFolder) { goto $nextFolder; }

Re: Keyboard shortcut to Jump to Next folder

Posted: 26 Apr 2016 22:51
by DarKHawK
This script jumps to first subfolder in the current main folder.

mainfolder
---subfolder1
---subfolder2
---subfolder3
---subfolder4
---subfolder5
---subfolder6

If I'm in subfolder 2-6 and I run the script I jump to subfolder1
What I need is that If I'm in subfolder2 for example and ran the script I would jump to subfolder3, and then subfolder4 and so on.

Correct me if I'm wrong, User > Manage Commands > Run Script > New > and past the script in the script edit window!

Re: Keyboard shortcut to Jump to Next folder

Posted: 26 Apr 2016 22:58
by highend
Not for me.

If I'm in subfolder1 and run the script it jumps to subfolder2, etc. When in subfolder6 it stays there ($nextFolder is empty -> No jump)

Re: Keyboard shortcut to Jump to Next folder

Posted: 27 Apr 2016 00:48
by DarKHawK
I found what's wrong.
If the root folder had "#" in it I get that strange behavior I described earlier.

#newfolder
--1
--2
--3
--4

Jumping from 2 to 3 makes a jump back 1. If I removed the "#" from the newfolder the script works fine.
Also happens with the next scinario when the "#" is a middle folder and not the root.

newfolder
--#
----1
----2
----3

I usually use the "#" a lot to rename my folders I want to keep near the top.
If there is no solution for it I can switch to any other character.
I'm very grateful either way.
Thank you.

Re: Keyboard shortcut to Jump to Next folder

Posted: 27 Apr 2016 04:31
by highend
Change:

Code: Select all

$curPos = gettokenindex(<curpath>, $parentFolders);
to

Code: Select all

$curPos = gettokenindex(<curpath>, $parentFolders, , "");
I've edited the script posted above to reflect this change...