~~Title: Miscellaneous Commands~~ == Directory Opus 13 - Detailed release notes == === {Codes} === * The `{clip}` code can now be asked to sanitize clipboard text: * `{clip|cleanfilename}` -- For use as a filename. * `{clip|cleanfilepath}` -- For use as an absolute path. * `{clip|cleanfilepathrel}` -- For use as a relative path. * `{filepath}` and similar codes can be asked to output paths in the WSL (Windows Subsystem for Linux) format: * This already happened automatically in WSL Script Function buttons, but you can now request it in normal buttons as well. * //Example:// `{filepath|wsl}` * `{file}` and similar codes now support regular expressions to test and manipulate the filename that's inserted into the command. * `{file|regex=}` -- Skip the file if the pattern doesn't match. * `{file|regex=|to=}` -- Output the result of the regex search & replace (if the pattern matches). * `{file|regex!=|to=}` -- As above but, if pattern doesn't match, it outputs the original name unchanged. * Use quotes around a pattern if it contains a %%|%% character. * Results from Evaluator code can be inserted into commands between `{=...=}`. For example, this would turn into "Echo 60": `Echo {=12*5=}` * The entire line can also be generated by the Evaluator, by prefixing it with a = character. For example, this would also turn into "Echo 60": `=return "Echo " + (12*5);`. ---- === @Modifiers === * Added positive versions of negative modifiers: * These make it easier to express a positive condition directly, instead of having to think in terms of a double negative. * `@showif` complements `@hideif`. * `@enableif`, `@enableifpath`, `@enableiftab` complement `@disableif`, `@disableifpath`, `@disableiftab`. * `@ifsel` complements `@disablenosel`. * `@perfile`: New modifier, changes the order multi-line commands execute on multiple files: * Affects commands that pass one file at a time, e.g. using `{filepath$}`. * Normally, each line in a command is run for all files before moving on to the next line. This makes sense sometimes, but not always. * With `@perfile`, you can specify a block of lines where the whole block runs for each file before moving on to the next file. * `@perfile:begin` marks the start of a block, and `@perfile:end` marks the end. * For example, with two files selected: File Alpha.txt File Bravo.txt This command: echo Line One -- {file$} echo Line Two -- {file$} Has this output: Line One -- "File Alpha.txt" Line One -- "File Bravo.txt" Line Two -- "File Alpha.txt" Line Two -- "File Bravo.txt" While this command: @perfile:begin echo Line One -- {file$} echo Line Two -- {file$} @perfile:end Has this output: Line One -- "File Alpha.txt" Line Two -- "File Alpha.txt" Line One -- "File Bravo.txt" Line Two -- "File Bravo.txt" * `@logusage` -- New modifier, updates the system Recent list with any files passed to external programs, and the programs themselves. * `@logusage` is turned on automatically for the Open With menu. * `@output` -- New modifier, outputs the rest of the line to the Sript Log from a normal command. * `@if`, and similar clauses, can now use Evaluator code to test various things: * Begin the condition with `=` to specify it is Evaluator code. * Variables `selfiles`, `seldirs`, `selitems`, return the number of selected items. * Variables `totalfiles`, `totaldirs`, `totalitems` return total number of items. * Variables `source` and `dest` return the source and destination paths. * Variables `source_shell` and `dest_shell` tell you if the source or destination are showing virtual Shell folders (e.g. Recycle Bin). * Variable `viewmode` returns the current file display mode. * In the viewer, variable `selimage` reports if part of the image is selected, and `fullscreen` if the viewer is fullscreen. * Evaluator code also has an `IsSelected()` function to test selections. Takes a wildcard pattern, optionally prefixed with "files:" or "dirs:", and returns the number of matching items. * IsChecked() and IsEnabled() can also be useful. * //Example 1:// Enable button only if there are exactly two .jpg files selected: @enableif:=IsSelected("*.jpg") == 2 * //Example 2:// Toggles between select-all and select-none: @if:=(selitems==totalitems) Select NONE @if:else Select ALL * //Example 3:// Alternative way to toggle between select-all and select-none: Select {=selitems==totalitems ? "NONE" : "ALL"=} * `@label` -- New modifier, uses Evaluator code to change a button's label dynamically. * Can use Evaluator functions and various variables, depending on context. * Variables include "dual" (true if a dual file display), "source" (source path), "dest" (destination path), "original_label" (the button's normal name, e.g. if you want to add to it instead of replace it entirely). * //Example:// `@label=viewmode=="details" ? "Details Mode" : "Another Mode"` * Button tooltips can change dynamically. See the Viewer toolbar's Edit > Copy for an example. * `@hideblock` -- New modifier, allows one or more toolbar items to be hidden based on a condition. * In particular, this allows entire sub-menus to be hidden conditionally, which wasn't possible before. * It can also simplify hiding multiple buttons, since the condition can be defined once instead of in each button. * On the default toolbars, it's used to hide the redundant Favorites menu from the "File Display" toolbar if the new "Favorites Bar" toolbar is turned on. * Before the (potentially) hidden Favorites menu, there's a button which runs this: @hideblock:begin @hideif:Toolbar NAME="Favorites Bar" TOGGLE That tests if the "Favorites Bar" toolbar is turned on, and starts hiding things if it is. After it is the sub-menu containing the Favorites list. Finally, there's another button which stops hiding things: @hideblock:end Anything between the two buttons will be hidden if the first button's `@hideif` condition is met (or `@showif` condition is not met). * `@disableiftab` -- New modifier, uses Evaluator code to disable items in the Folder Tab context menu, which is now customizable. * Variable `sel` gives the selected tab index (zero-based; -1 if the tab bar background is right-clicked). * Variable `dual` true if in a dual-display window. * Variable `countdual` gives number of tabs on the opposite side of a dual-display window. * Variable `selr` gives number of tabs to the right of the selected one. * Examples: * `@disableiftab:sel == -1` -- Disable if no tab is selected. * `@disableiftab:sel > 1` -- Disable unless the first or second tab is selected. * `@disableiftab:selr == 0` -- Disable if the rightmost tab is selected. * `@disableiftab:(sel == -1) || dual` -- Disable if no tab selected, or in dual display. * Added `@enableifpath:shell`, `@disableifpath:shell`, etc. to test if the current folder is a virtual Shell namespace. * Default toolbars use this to disable the "Details + Thumbnails" button in Shell folders like Recycle Bin, where it won't work. * Can also use Evaluator with corresponding `source_shell` and `dest_shell` variables. E.g. `@disableif:=source_shell` * `@eval` and `@evalalways` -- Runs Evaluator code as part of a dynamic test, and optionally as part of the command itself. * Typically used to set Evaluator variables which are used on later lines. * Example: @eval:type = PathType(source); fIsFileSystem = (type == "shell" || type == "filesys") @showif:=fIsFileSystem @label:fIsFileSystem ? ("Open " + FilePart(DisplayName(source)) + " in Explorer") : ("Disabled (" + type + ")") * Code after `@eval:` is only run when dynamically updating the button's label, visibility and enabled/disabled state. Not when the button is clicked. * Code after `@evalalways:` runs in //both// situations, allowing you to set up variables which are used both when executing commands and updating their labels, etc. * Evaluator code can also be inserted in the middle of normal command lines using the `{=...=}` syntax. * Evaluator code can also generate an entire command line, by starting the line with the `=` character. * `@admin:no` -- Prevent subsequent lines from triggering UAC prompts. `@admin:yes` can be used to re-enable them. * `@ifexists` -- You can specify a wildcard in the final path component, if the path is prefixed with `wild:`. * //Example:// `@ifexists:wild:C:\Win*` * `@icon`: * Now allows quoted icon paths, fixing an issue with paths containing commas. * Can run Evaluator code instead of testing an internal command. * //Example:// `@icon:"file.ico",=` * Can also use Evaluator to return an icon path directly. * //Example:// `@icon=InStr(source, "production")!=-1 ? "Prod.ico" : "Staging.ico"` * `@ctx` -- New modifier which allows Evaluator code to work with internal commands which generate a list of buttons. * The full manual will have more detail, but @ctx is very esoteric. Most people will never need to use or understand it. * It exists so we could make the new Favorites Bar display a named branch of the Favorites tree, where the name changes for different languages/locales. ---- === New commands and arguments === * These are only the commands that didn't fit in other sections. * Commands to change Preferences settings: * `Set DELRECYCLECONFIRM` -- Turn Recycle Bin confirmations on and off. * `Set DELRECYCLEBIN` -- Turn use of the Recycle Bin on and off. * `Set FRIENDLYDATES` -- Controls whether friendly dates ("Today", "Monday", etc.) are displayed. * `Set MINIMIZEPROGRESS=toggle` -- Toggle the "Minimize progress indicators automatically" setting. * `Set QUICKFILTERFLAGS` -- Change various Filter Bar options: * New "set" and "clear" parameters tell it to only set or clear flags, instead of toggling them. * Toggle behavior changed to only affect the specified flag(s) and any mutually-exclusive flags. * New parameters to override (on or off) the Preferences settings for Flat View filtering, regular expressions, "ignore diacritics", "any word" and "partial matching". * `Set CALCFOLDERSIZES=selected` -- Sets "Calculate folder sizes automatically" to "selected folders only". * You can also use them in conditional tests, to see if the corresponding options are on. * `Go BACK` and `Go FORWARD` now work in conjunction with NEW, NEWTAB, OPENINDUAL, etc. arguments to open a folder from the current tab's history into another tab or window. * Commands that dynamically generate a list of buttons now have a HEADING argument which can add a heading before the list. * If the list is empty, no heading is added. (That's why it exists, as opposed to adding a simple, static heading before the list which would look silly when there is no list.) * "HEADING" by itself creates a label with the same name as the button it comes from (the one generating the list). * "HEADING=Xyz" uses "Xyz" as the heading instead. * Used in various places in the new default toolbars. * //Example:// `Go DRIVEBUTTONS=lettersbeforelabels HEADING` * The `Favorites` and `Prefs LAYOUTLIST` commands have new `MENUMARKERS` argument which causes arrow glyphs to be shown for any menus in the top-level of the generated list of buttons. * `Favorites EXCLUDEBRANCH` -- Allows wildcards to exclude branches of the Favorites list when displaying it on toolbars/menus, * The Favorites Bar's "Other Favorites" menu uses this to avoid showing a second copy of the "Favorites Bar" branch, which is shown on the toolbar itself. * `Favorites BRANCH` -- Filters the Favorites list to a specified branch. (Can also be done via `PATH` argument, but `BRANCH` has easier syntax for a single branch.) * `Favorites AUTOCREATE` -- Creates a specified Favorites branch if it doesn't already exist, while displaying it on a toolbar/menu. * `Close SYSTEM` -- Added `sleep` and `suspend` options. * `Copy TO` -- Copy commands that use the `TO` argument are no longer automatically queued. * This is because the destination path isn't evaluated until the command starts, at which point its queue name (if any) must already be known. * The `QUEUE` argument can still be used to explicitly add the operation to a named queue. * `Clipboard COPYIMAGE` -- Copies the selected image file to the clipboard as bitmap data, for pasting into other programs. * `Clipboard COPYNAMES=noexts` -- Removes file extensions from the names it puts in the clipboard. * `FILTERDEF` argument added to several commands to let you specify the details of complex filters as part of the command itself: * Essentially, any command which could take a named filter can now be given the filter definition directly, keeping everything in one place. * This also allows scripts to modify filter details on the fly, or generate entire filters at runtime. * Also allows Evaluator code to be used for filtering. * Discussed more in the separate [[find|Find]] section. * `Find FILTERDEF` -- Filters which files/folders are found. Also works with the Duplicate Files finder and Synchronize tools, which can be run via the Find command. * `SetAttr FILTERDEF` -- Filters which files/folders are changed. * `Print FOLDER FILTERDEF` -- Filters which files/folders are included. * `Copy FILTERDEF` -- Filters which files/folders are copied/moved. * `Delete FILTERDEF` -- Filters which files/folders are deleted. * A single command can now be split across multiple lines in the editor, with arguments on subsequent lines. * This is particularly useful with `FILTERDEF`, mentioned above. * It is also useful with "raw" /R arguments in general, which ordinarily swallow the rest of the command line (and therefore made it impossible to use two in the same command). * To move an argument to its own line, syntax requires that either... * Everything is on a single line, surrounded by %%[[%% and %%]]%%. * Or: The `[[` and `]]` are on lines by themselves, with everything else between them. * (This is similar to the existing syntax for embedded commands between single `[` and `]` characters.) * Example: Find IN C:\ [[QUERY *.jpg]] [[ FILTERDEF size match > 100 kb and size match < 200 kb ]] * `Set FORMATLOCK`: * Now works on (only) the current file display, without any "left" or "right" parameter. Includes from the right-click menu on the status bar padlock/info icon. * Added "all" parameter to get the old behaviour. `Set FORMATLOCK=toggle,all` will toggle the state for both sides at once. * `Set FLATVIEW=KeepFormat` -- New "KeepFormat" parameter lets you toggle Flat View without triggering the special folder format for it. * Similar to disabling the "Flat View" folder format entirely, but only for specific commands. * Can be useful if you usually want the Location column added for Flat View, but not when using a particular button. * Also useful if you want to set up columns and filtering in the file display before switching Flat View on, to reduce overhead (calculating columns you don't want) and visual noise (things appearing in the file display, only to be removed immediately). * For example, this toggles Flat View with all files hidden, the Full Path column visible, and the Location and Relative Location columns removed, if present: @if:Set FLATVIEW=Grouped Set FLATVIEW=Off,KeepFormat Set HIDEFILTERFILENAME Set FORMAT=!folder @if:else Set HIDEFILTERFILENAME=* Set COLUMNSREMOVE=path,pathrel Set COLUMNSADD=fullpath(1) Set FLATVIEW=Grouped,KeepFormat * `Set NOOP` -- Guaranteed to do nothing. Can be used to make a hotkey which does nothing, so the keypress won't trigger Find-As-You-Type. * Date/Time formatting strings, used in various places, can now take strings beginning with "A#" to combine date and time codes into a single format string. (Instead of requiring separate "D#" and "T#" format strings.) * User Commands can use the Evaluator to test their arguments, via the Arg() function. For example, with a User Command argument template of NAME/K: @if:=InStr(Arg("NAME"), "jon") echo Hi Jon! @if:else echo Who are you? * `GetSizes HASH=` -- Replaces older "GetSizes MD5" and "GetSizes SHA" (which still work). * Possible type keywords are: md5, sha1, sha256, sha512, crc32, crc32_php, crc32_php_rev, blake3. * `Clipboard COPYNAMES=hash:` -- Replaces older "Clipboard COPYNAMES=hash", "hash2", "hash3", etc. (which still work). * Possible type keywords are the same as with GetSizes, above. * The three different output formats remain, and can now be selected with "fmt:X". * For example, "Clipboard COPYNAMES=hash:sha1,fmt:2" is the equivalent of the old "Clipboard COPYNAMES=hash5". * `Favorites NOLABELS` -- Now only hides labels at the top-level. Sub-menus now always include labels. * `Set EVALUATORDISABLE` -- Can be used to block all Evaluator code from running (until re-enabled), for troubleshooting. * `Copy INSTALLFONT=user` -- Installs a font for the current user rather than for all users. * `Set SIDE=...` -- Can be used in conditionals to test if a button is on a Location Bar toolbar tied to the left (top) or right (bottom) side. * `Properties POSITION=...` -- Lets you specify where the Properties dialog will open. ---- Next: [[release_history:opus13_detailed:misc_scripting]]