Thank you very much, Leo. I had never thought about such a button, but once I had added it and started working, I immediately realised how much fiddling about it eliminated for me. I now have two beaut new hotkeys, one for "Next Sibling" and one for "Previous Sibling".
As tbone also asks, could you possibly not skip empty directories — or else provide a "NoSkipEmpty" switch (or make this the default and provide a "SkipEmpty" switch). For example, at the start of each year, I automatically generate various empty directories, which I then populate during the year as things come in. I am finding the buttons' behaviours confusing in this situation, because I don't know which directories are still empty, and so I don't know how many times to press the hotkey. I also can't get to some still-empty directory that I am actually aiming for.
I have a GoEx command in the making, that combines some other GO-related things and adds SKIPEMPTY and WRAPASK to this beauty.
I started to create rather multifunctional commands recently, as I lose oversight of what's in my script addins folder and because some of the contributions just don't evolve once published. They sometimes serve more as an example than something that is under maintanance, don't know what this one will end up though. If Leo is willing to improve it, you're just spoilt for choice I guess. o)
I installed the script and created a button using the GORELATIVE command. Since I am not as sharp as you guys, all I found when I used the button was script errors. Please add a button with the script download. Thanks!
Root post updated to v1.1. No longer skips empty folders.
Added two sample buttons, too.
Thanks Leo. No problems using the updated script and the two buttons. Very nice.
Thanks again, Leo, for the changed behaviour with empty directories — it's perfect now as far as I am concerned. My brother has 65537 siblings, but I don't, so that limitation doesn't worry me.
Leo's GoRelative, with no more scripting, allows two further very simple buttons that navigate parallel directory structures. They are also proving very useful to me, and I thought it may be worth posting them.
I have some systems of parallel directories based on years. For example, in my records, the directory 2015 has subdirectories
Banking, BankingStatements, Super, Tax, . . . and so do the directories 2014, 2013, 2012, . . . When I am in 2015\Tax, I often want to go directly to the previous parallel directory 2014\Tax, or further back to 2013\Tax, and then return to 2015\Tax.
The following button use GoRelative to go to the next parallel directory:
GoRelative Sibling=Next Wrap SkipHidden
and changing "Next" to "Prev" gives a button that goes to the previous parallel directory. The last line throws an error if there is no parallel directory. The buttons are easily adapted to any deeper parallel nesting.
A very useful script, good work.
Dopus and @leo strikes again!
I just came to the forums to look/ask for exactly this type of button.
You are making my life a living hell! Because with the direction windows is going it's time to seriously think about moving on to linux, imho.
But how can I do that, when there is no DOPus on linux? Huh!!!???
Very useful script Leo !
just found it, I will use it a lot.
@Julianon, I don't have that kind of directory structure, but i have to say the idea is great and should prove very useful to many
Nice. I was looking for something like that for some time, decided to search for it and found it.
I've taken the dangerous liberty of adding some bells and whistles to leo's script. Apologies, leo, in advance for my inevitable mistakes and misunderstandings. In particular, I'm not confident that I've understood the significance of all the checks in the code.
I rewrote it in JScript because I don't know VBScript, and renamed it from Go_to_Relative.vbs to GoRelative.js to avoid confusion with leo's script.
Drive-hopping is added. That is, if the script climbs to the root of a drive rather than a directory, then it will hop to the next or previous drive in alphabetical order.
— This drivehopping ignores drives that are not ready, but otherwise does not distinguish between types of drives (one could easily add such code).
— A new switch argument
ChooseDrive of type /S triggers a dialogue for the user to choose the target drive, rather than have it chosen automatically.
— Another new argument
OmitDrives of type /K can avoid annoying things such as HP's naming of their backup drive as D: drive. For example,
OmitDrives=D:\,M:\,Z:\ will also work).
More significantly, a new argument
Depth, of type /O, allows automatic navigation through parallel directory structures. By itself or with an invalid value, it triggers a dialogue, otherwise it should have a positive whole number as its value.
For example, suppose that there are two directories:
Suppose that one is working in the
...\Lessons\2017\Class09 directory, and wants to go to
...\Lessons\2016\Class09 to pick up something from last year's directory. The following two buttons swap between them:
GoRelative Depth=2 Sibling=Previous (or
GoRelative Depth=2 Sibling=Next (or
Depth=3 extends this climb one more step.
Suppose that there are two directories:
The following two buttons swap between them:
GoRelative Sibling=Previous Depth=3
GoRelative Sibling=Next Depth=3
- And so on.
Depth=4 would be for
For depths greater than 1, the tree-climbing may comes to a drive prematurely. In this situation, the climbing stops, and drive-hopping begins.
Once the depth is greater than 1, the parallel target directory may not exist. When this happens, the script goes as far back down the target tree as far as it can, then issues a warning message.
Sibling argument is now of type /O. The chosen sibling may be 1, 2, 3, ... away, which may be useful when the depth is greater than 1.
When the argument is absent (not recommended), it defaults to the Next sibling directory (or drive).
Sibling can take any non-zero integer, where positive integers move forward that many items through the siblings, and negative numbers move backwards through the siblings.
Sibling can also take, as it did before, the values
Previous (=-1) or
Prev, which move to the next or previous sibling.
By itself or with an invalid value, the argument
Sibling triggers a dialogue.
The switch argument
Wrap of type /S now uses modulo arithmetic in the obvious way.
In particular, the command
GoRelative with no
Sibling argument is the same as
GoRelative Sibling=Next or
The default is now to include hidden files, but exclude system files. These defaults can be changed with two switches of type /S:
SkipHidden (unchanged) and
In a DOpus thread a year or so ago, I posted a system using the keys F12, F11, F10 and F9, for opening directories in another tab, the other dual panel, or another single- or dual-panel lister. These methods now work consistently with the GoRelative commands.
I had already implemented, and posted above, a less elaborate version of 'depth' using leo's unaltered script combined with ordinary DOpus commands. But the F12-F9 methods did not work consistently with these earlier 'depth' buttons, perhaps because of timing issues, and this was my original motivation for fiddling with leo's script.
- A new switch
UserDefinedGo, of type /S, now changes the final command from DOpus' normal Go command to the user-defined command
A@Go used in the F12--F9 system. Obviously, ignore this switch entirely unless the F12--F9 system is already installed and running.
[To recapitulate this system, before running the script:
Press F12 to open the new folder in a new tab.
Press F11 to open it in the dual panel.
Press F12 and F11 to open it in a new tab of the dual panel.
Press F10 to open it in a single-panel lister.
Press F9 to open it in a dual-panel lister.
See the earlier thread for the code to attach to F12-F9 and the corresponding menubar icons, where the hotkeys are arbitrary, or could be omitted.]
Examples (without the
GoRelative Sibling=Next Wrap Depth=1 — Totally standard
GoRelative Sibling=Previous Depth ChooseDrive SkipHidden — Dialogues for the depth and the drive.
GoRelative Sibling Wrap Depth=2 OmitDrives=M:,Z: — Dialogue for the sibling, and Drives M: and Z: are omitted if drive-hopping is necessary.
The file below is the adapted GoRelative.js script. I was not sure how to handle the copyright protocols, which may well need adjusting.
First, disable the old addon Go_to_Relative.vbs if it is installed, otherwise DOpus will have two conflicting commands GoRelative. The easiest way is to navigate to the addons directory and rename its extension to .vbsx — this is easily reversed in the event of blunders by me.
Download the new file GoRelative.js.txt below, open the scripts window by Preferences > Toolbars > Scripts, and drag the downloaded file to its right-hand panel.
Excellent work, gentlemen!
Is there a way to make this work from the standalone image viewer? This sequence works manually, but not from a viewer hot key:
GoRelative Sibling=Next Wrap Depth=1
What you're doing won't work because those commands are all being run in the context of the viewer, not the file display you're trying to do things in.
Navigating the file display and/or changing the selection in the UI just to feed different files to commands is rarely a good idea, even when it does work. It's fragile to clicks you might do at the same time, and the timing of things, and also messes around with the file display as a side-effect of something else, when you might not want the file display to be messed around with. (In this case, the file display may not even be there, too.)
If you want to jump the viewer to the first file in the next folder, you could do that using a script which works out which file to display and tells the viewer to display it. That's the approach I'd go for. (I can write the script in a while, but probably won't have time before 12.10 is released as I'm flat-out finishing things for that right now.)
Thanks for the explanation. A script would of course be nice, but no rush, 12.10 has definitely higher priority!
Great one! Thanks for sharing.
Quick question. Would be difficult to modify this script to move up in down "in depth" based on the directory creation date rather than alphabetically? Thank you in advance.
It's possible, but not completely trivial. I'll try to take a look when I have a spare moment, but can't promise.
Thank you Leo, very much appreciated.