Expand Folders is a script command for Directory Opus, which simplifies the expansion/collapse of entire branches in all or selected folders when using Expandable Folders feature in the current file display.
Its main features are:
- Expand all folders in the current file display to their maximum depth (all levels).
- Expand only selected folders.
- Expand only top level folders.
- Expand all/selected up to the desired level.
- Collapse all/selected expanded folders.
- Smart choice for decide between expand or collapse.
- Optionally when expanding folders, select files/folders within.
- Save and restore a snapshot of the current expanded/collapsed state of the folders in a tab.
How To Install
Download the file below. Then run Prefs SCRIPTINSTALL
and select the downloaded file.
IMPORTANT: Needs at least v13.7.5
v2.1.0 : ExpandFolders.opusscriptinstall
Usage
You can use Expand Folders as a command, using ExpandFolders
.
When used this way, it will expand the selected folders to their maximum depth. If no folders are selected, all folders in the current file display are used.
In addition, the command has the following arguments:
Command Arguments
Argument | Type | Values | Description |
---|---|---|---|
ALL | /S | (no value) | Use all folders in the current file display. If not especified, when there's no items selected, `ALL` will be implicit. |
COLLAPSE | /O | (no value) | Collapse folders if they are expanded. Can be used in conjunction with ALL.
When used alone, selecting files will collapse the parent folder above. If folders are selected, they will be collapsed, if possible. |
parent | Use COLLAPSE=parent to change the difference between files and folders, and selecting subfolders will collapse their parent folders. | ||
EXPAND | /O | (no value) | This argument will be the default unless COLLAPSE or TOGGLE are present. Use it to expand all or only selected folders. |
int | Where int is a integer referring to a level. Use EXPAND=int (eg. EXPAND=2) to expand till the desired level. | ||
top | Use EXPAND=top to only expand the first level. | ||
SELECT | /O | (no value) | Select all items beneath folders expanded by this command. |
dirs | Select dirs only, excluding the files. | ||
TOGGLE | /O | (no value) | Toggle between the two states, based on the expanded condition for the selected items (or all if nothing selected or ALL is used). |
expandtop | Use TOGGLE=expandtop to only expand the first level, if TOGGLE follows that direction. | ||
colparent | Use TOGGLE=colparent to enable parent argument when collapsing, if TOGGLE follows that direction. | ||
int | Use TOGGLE=int to refer the number of levels to expand, if TOGGLE follows that direction. | ||
SNAPSHOT | /O | (no value) | Save a snapshot of the current expanded/collapsed state of the folders in the tab. Additionally, save the name of the item that will receive focus when restoring this snapshot, according to the value of `Focus when Restore`. |
restore | Restore the previously saved state for the tab, if it exists. | ||
CLEARSNAPSHOTS | /S | (no value) | Delete all saved snapshots. |
Configuration
Config | Value Type | Description |
---|---|---|
Expanding Dialog Delay | integer | Delay in milliseconds before the expansion waiting dialog appears.
0 or less means no delay. Values larger than the time it takes for the expansion to occur have no effect on the command's duration. |
Max Timeout when Expanding | integer | Maximum time in milliseconds that the command will wait after each level expansion to abort the entire command.
If value is less or equal to 0, or greater than 90000, the value is set as 90000 (90s) |
Clear Snapshots after X days | integer | Number of days that a snapshot remains stored in disk.
Set to 0 to delete all saved snapshots on DO startup. Maximum value permitted is 30 days. |
Focus when Restore | Option | When restoring a snapshot, choose which item should gain focus.
Saved focused item : Current item with focus when the snapshot was saved. First saved expanded folder : First expanded folder when the snapshot was saved. No change : No change in focus when restoring. |
log level | Option | Logging level to be displayed. OFF to show only errors.
DEBUG to show all messages. STANDARD to show only the most relevant information. WARNING to show messages that needs your attention. |
Examples
Expand all/selected folders in current file display
ExpandFolders EXPAND
Expand Folders.dcf (345 Bytes)
Expand all folders in current file display, then save a snapshot
ExpandFolders EXPAND ALL SNAPSHOT
Expand all folders to first level in current file display
ExpandFolders EXPAND=top ALL
Collapse all expanded folders in current file display
ExpandFolders COLLAPSE ALL
Collapse All Folders.dcf (343 Bytes)
Toggle expanded state for all/selected items
ExpandFolders TOGGLE
Toggle expanded state for all/selected items. If expanded, expand up to 3 levels and select only folders within
ExpandFolders TOGGLE=3 SELECT=dirs
Restore a previously saved snapshot
ExpandFolders SNAPSHOT=restore
Expand selected folders (or all if nothing selected) only the top level.
Use it in conjunction with Shift for expand at max depth.
Also, use it in conjunction with Ctrl for select items beneath expanded folders.
=return "ExpandFolders EXPAND" + (KeyDown("shift") ? "" : "=top") + (KeyDown("ctrl") ? " SELECT" : "");
Expand All_Selected.dcf (563 Bytes)
Notes
- The command is not allowed to be used if grouping or flat view is active.
- Due to the command detecting as expanded folders those with nested items as children, in certain parts of the command, empty expanded folders may not be detected as such.
- When expanding a branch with a huge number of items, there may be a delay because DOpus needs to read the new items' info.
- If you want to delete ALL snapshots when starting DO, set
Clear Snapshots after X days
equal to or less than 0. Clear Snapshots after X days
accepts 30 as the maximum value. This is to prevent ending up with a large amount of saved data.- The command needs to read some info from your DO preferences file itself, to properly collapse folders in all scenarios. So if you modify the state of
Preferences / File Displays / Folder Expansion > Collapse subfolders within collapsed folders
, the command may not detect the change immediately.
Changelog
v2.1.0 (Jul 12, 2024) : ExpandFolders.opusscriptinstall (8.2 KB)
- Improved internal script intercommunication thanks to new additions in DO.
- The script can now be used simultaneously in each lister.
- Other minor improvements.
Full changelog
v2.0.1 (May 14, 2024): ExpandFolders.opusscriptinstall (8.1 KB)
- Quick fix for
TOGGLE
not properly recognizing expanded folders when they're not at the top level.
v2.0.0 (May 13, 2024):
- Added new arguments:
SNAPSHOT
: Allows saving the current state of a path, related to expanded/collapsed folders state and the focused item (depending on the configuration). Can be used with other arguments.SNAPSHOT=restore
: Allows restoring a previously saved state, along with the focused item (depending on the configuration). Cannot be used with other arguments.CLEARSNAPSHOTS
: Deletes ALL currently saved snapshots.
- Enhanced the collapsing part. It now detects whether
Preferences / File Displays / Folder Expansion > Collapse subfolders within collapsed folders
is disabled and collapses all levels accordingly, even in that scenario. - New entries in Script Configuration:
Clear Snapshots after X days
andFocus when restoring
(both explained in Configuration). - Other minor corrections.
v1.6.0 (Apr 21, 2024):
- Now the dialog use font name/size configured in Preferences / Colors and Fonts / Fonts > Dialogs.
SELECT
can be used in Libraries.- Better logging system.
- Minor improvements.
v1.5.1 (Mar 09, 2024):
- Added in Script Config a new value : Expanding Dialog Delay, allows you to set the delay time before showing the expanding dialog (useful for shorter expansions). Default is 1 second (1000).
- Minor changes.
v1.5.0 (Mar 01, 2024):
- Improved overall logic when expanding/collapsing.
- New int value for
EXPAND
andTOGGLE
, to refer to an specific level when expanding. levels
andcollevels
values have been removed fromCOLLAPSE
andTOGGLE
respectively. Now the command respect the option in Preferences / File Displays / Folder Expansion : Collapse sub-folders within collapsed folders.- Added in Script Config a new value : Max Timeout when Expanding, to customize the maximum time in milliseconds that the command will wait after each level expansion to abort the entire command. By default is 15 seconds (15000).
v1.4.0 (Feb 28, 20024);
- Internal build.
v1.3.0 (Feb 22, 2024):
COLLAPSE
has a new value :levels
, to effectively collapse all the expanded folders in all levels.- Added
colparent
andcollevels
values forTOGGLE
, to enable the corresponding values for collapse. - A problem with the custom progress dialog that interfered with other listers/windows, minimizing/bringing them to the front, has been fixed.
v1.2.1 (Feb 11, 2024):
- Now when expanding only the top level, is no longer initialized a new thread.
- Added
SELECT
andSELECT=dirs
, which allows to select the files/dirs beneath the new expanded folders by the command.
v1.1.0 (Feb 02, 2024):
- Added new argument:
TOGGLE
andTOGGLE=expandtop
, for toggle between two states - New custom progress dialog when expanding.
v1.0.1 (Jan 24, 2024):
- Added new argument:
EXPAND
and the subvalueEXPAND=top
to only expand the first level in folders. - Now when collapsing, you can select files to collapse their parent folder.
- Added new subvalue
COLLAPSE=parent
, to collapse parents for selected folders as well.
v1.0.0 (Jan 23, 2024) Initial release