### Variable Persistence Example (VBScript) Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Avars Example demonstrating how to check for, get, set, and make a variable persistent using VBScript. ```APIDOC ## Variable Persistence Example (VBScript) ### Description This example shows how to manage variables, including checking their existence, retrieving their values, setting new values, and enabling persistence. ### Code ```vbscript Dim varName, varValue1, varValue2 varName = "MyVariableName" if (DOpus.Vars.Exists(varName)) then varValue1 = DOpus.Vars.Get(varName) DOpus.Output varName & " = " & varValue1 else DOpus.Output varName & " does not exist yet." end if varValue2 = "My Variable Value" DOpus.Vars.Set varName, varValue2 DOpus.Vars(varName).persist = True ``` ``` -------------------------------- ### Format Method Examples Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Adate Examples of using the Format method with different arguments. ```APIDOC ## Format Method Examples ### Description Illustrative examples of the Format method's capabilities. ### Examples - **Get date only, day names off:** ```javascript myDate.Format("d","n") ``` - **Get date and time, day names on, seconds off:** ```javascript myDate.Format("","Ns") ``` - **Custom format:** ```javascript myDate.Format("D#yyyy-MM-dd T#HH:mm:ss") // Example output: 2023-07-28 15:45:26 ``` ``` -------------------------------- ### CLI QUICKSEARCHENGINE Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Use QUICKSEARCHENGINE before QUICKSEARCH when QUICKSEARCH consumes the rest of the command line. ```cli CLI QUICKSEARCHENGINE everything,case QUICKSEARCH A*.jpg ``` -------------------------------- ### Variable Persistence Example (JScript) Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Avars Example demonstrating how to check for, get, set, and make a variable persistent using JScript. ```APIDOC ## Variable Persistence Example (JScript) ### Description This example shows how to manage variables, including checking their existence, retrieving their values, setting new values, and enabling persistence. ### Code ```javascript var varName = "MyVariableName"; if (DOpus.Vars.Exists(varName)) { var varValue1 = DOpus.Vars.Get(varName); DOpus.Output(varName + " = " + varValue1); } else { DOpus.Output(varName + " does not exist yet."); } var varValue2 = "My Variable Value"; DOpus.Vars.Set(varName, varValue2); DOpus.Vars(varName).persist = true; ``` ``` -------------------------------- ### CLI QUICKSELECT with pattern Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Initializes the find-as-you-type field in Select mode with a specified pattern. ```cli CLI QUICKSELECT *.doc ``` -------------------------------- ### JScript Example Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Aunorderedset Example demonstrating the creation and usage of the UnorderedSet object in JScript. ```APIDOC ## JScript Example ```javascript var us = DOpus.Create.UnorderedSet(); us.insert("cat"); us.insert("cat"); // No effect, as "cat" already inserted. us.insert("dog"); us.insert(DOpus.FSUtil.NewPath("C:\\")); us.insert(DOpus.FSUtil.NewPath("C:\\")); // Inserts a second C:\ Path object! var p = DOpus.FSUtil.NewPath("D:\\"); us.insert(p); us.insert(p); // No effect, as p already inserted. DOpus.Output("count: " + us.count); for (var e = new Enumerator(us); !e.atEnd(); e.moveNext()) { DOpus.Output("Item: " + e.item()); } ``` **Output:** ``` count: 5 Item: cat Item: dog Item: D:\ Item: C:\ Item: C:\ ``` ``` -------------------------------- ### CLI QUICKTABS with pattern Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Initializes the find-as-you-type field in Tabs mode with specified text. ```cli CLI QUICKTABS docu ``` -------------------------------- ### CLI QUICKWSLCMD with command Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Initializes the find-as-you-type field in WSL script mode with a specified command. ```cli CLI QUICKWSLCMD ls ``` -------------------------------- ### UnorderedSet Output Example Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Aunorderedset Shows the expected output from the preceding JScript example, illustrating the count and the items stored in the UnorderedSet. The order of items may vary. ```text count: 5 Item: cat Item: dog Item: D:\ Item: C:\ Item: C:\ ``` -------------------------------- ### Check, Get, and Set Variables with Persistence (VBScript) Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Avars This VBScript example demonstrates how to check if a variable exists, retrieve its value, and set a new value. It also shows how to enable persistence for the variable, ensuring it's saved across sessions. ```vbscript Dim varName, varValue1, varValue2 varName = "MyVariableName" if (DOpus.Vars.Exists(varName)) then varValue1 = DOpus.Vars.Get(varName) DOpus.Output varName & " = " & varValue1 else DOpus.Output varName & " does not exist yet." end if varValue2 = "My Variable Value" DOpus.Vars.Set varName, varValue2 DOpus.Vars(varName).persist = True ``` -------------------------------- ### Configure and Start Synchronization in Panel Source: https://docs.dopus.com/doku.php?id=release_history%3Aopus13_detailed%3Asynchronize The Find SYNC RUNINPANEL command allows for configuring the synchronization panel and starting the operation with a single command. ```dopuscript Find SYNC RUNINPANEL ``` -------------------------------- ### Example of initial search results Source: https://docs.dopus.com/doku.php?id=basic_concepts%3Asearching_and_filtering%3Afind_files Demonstrates the results of searching for files containing 'Directory' in their names. ```text Directory Listing.txt Directory Opus.txt ``` -------------------------------- ### CLI SCRIPTMODE (no value) Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Displays the CLI in Script Mode for testing scripts before adding them to buttons. ```cli CLI SCRIPTMODE ``` -------------------------------- ### CLI QUICKSELECT (no value) Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Displays the find-as-you-type field in Select mode to select files by wildcard pattern. ```cli CLI QUICKSELECT ``` -------------------------------- ### Simple Wildcard Rename Example Source: https://docs.dopus.com/doku.php?id=file_operations%3Arenaming_files%3Asimple_wildcard_rename This example demonstrates renaming files starting with 'Img_' and ending with '.jpg'. The asterisk preserves the middle part of the filename. The operation is case-insensitive. ```text Img_*.jpg IMG*.jpg ``` -------------------------------- ### Generated Batch File Example Source: https://docs.dopus.com/doku.php?id=customize%3Acreating_your_own_buttons%3Ams-dos_batch_commands This is an example of the temporary batch file Opus creates when running the directory listing function. It includes standard MS-DOS commands for setup and execution. ```batch @echo off chcp 1252 > nul C: cd "\Users\Jon\Documents" dir /w > "C:\Test\Documents.txt" ``` -------------------------------- ### Launch External Program with Arguments Source: https://docs.dopus.com/doku.php?id=customize%3Acreating_your_own_buttons%3Acommand_editor%3Asimple_command_editor This example shows how to launch an external program, Notepad, and pass it the name of the first selected file in the file display. External control codes are used for this purpose. ```opus-command "C:\\Windows\\notepad.exe" {file:1} ``` -------------------------------- ### OnStartup Event Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_events%3Aonstartup This event is triggered only when Opus starts up. It is intended for script add-ins that are already installed. If a script is installed while Opus is running, it will not receive the OnStartup event until the next time Opus is launched. ```APIDOC ## OnStartup ### Description The **OnStartup** event can be implemented by a script add-in to receive notification when Opus starts up. ### Method Name OnStartup ### Argument Type StartupData ### Return Type _none_ ### Description This event is only triggered when Opus starts up, therefore only script add-ins that are already installed will receive it. If a script is installed when Opus is already running it won't receive **OnStartup** until the next time Opus is started. ``` -------------------------------- ### CLI QUICKSELECT with noselect prefix Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Initializes the find-as-you-type field in Select mode with a pattern, placing the cursor at the end. ```cli CLI QUICKSELECT noselect:*.doc ``` -------------------------------- ### Extract Substring with Mid Function Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Amid Use the Mid function to get a specified number of characters from a string, starting at a given position. If length is omitted, it returns characters from the start position to the end of the string. ```dopus_evaluator Output( Mid("Hello To You", 6, 2) ); --> To ``` -------------------------------- ### Multi-line Command Example Source: https://docs.dopus.com/doku.php?id=customize%3Acreating_your_own_buttons%3Acommand_editor%3Aadvanced_command_editor Complex commands can span multiple lines. Lines starting with [[ are treated as continuations of the previous command. ```dopuscript Find IN C:\ [[QUERY *.jpg]] [[ FILTERDEF size match > 100 kb and size match < 200 kb ]] ``` -------------------------------- ### Count Selected Directories Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Afilecount Verifies if exactly five selected directories starting with 'new' exist. This example shows how to count only selected items and filter for directories. ```dopus_scripting if (FileCount(true, "dirs:new*") == 5) { ... } ``` -------------------------------- ### Run Notepad with Selected File Source: https://docs.dopus.com/doku.php?id=customize%3Acreating_your_own_buttons%3Asynchronous_and_asynchronous_functions This example demonstrates how a command to run Notepad with a selected file behaves differently based on whether it's executed synchronously or asynchronously, especially when multiple files are selected. ```batch notepad.exe {f} ``` -------------------------------- ### Get Recycle Bin Item Count Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Arecyclebin Use the 'c' mode to retrieve the number of items currently in the recycle bin. This example displays the count for the C drive. ```dopus_evaluator Output("Recycle bin on drive C contains " + RecycleBin("c","c") + " items."); --> Recycle bin on drive C contains 198 items. ``` -------------------------------- ### Initiate Synchronize Process (Default) Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Afind Initiates the synchronization process by comparing files. This is the first step in automating the Synchronize tool. Subsequent commands like 'Copy SYNC' and 'Set CLEARSYNC' are required to complete the operation. ```opuscmd Find SYNC FROM "D:\Work" TO "D:\Backups" RECURSE COMPARE=newer HIDEUNAFFECTED Copy SYNC Set CLEARSYNC ``` -------------------------------- ### Compare String Prefix with StrCmp Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Astrcmp Use StrCmp to check if a string starts with a specific prefix. This example compares the first 7 characters of the 'name' variable against 'backup-'. ```javascript if (StrCmp(name, "backup-", 7) == 0) { ... } // name begins with "backup-" ``` -------------------------------- ### Convert Character Code to Character - Chr Function Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Achr Use the Chr function to get the character representation of a given ANSI/Unicode code. This example demonstrates converting the code 65 to its character 'A'. ```dopus_evaluator Output( Chr(65) ); --> A ``` -------------------------------- ### CLI QUICKWSLCMD with noselect prefix Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Initializes the find-as-you-type field in WSL script mode with a command, placing the cursor at the end. ```cli CLI QUICKWSLCMD noselect:ls ``` -------------------------------- ### Go TOFRONT Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Ago Brings the Lister to the front and makes it the active window. ```APIDOC ## Go TOFRONT ### Description Makes the Lister the active window and brings it to the front. Typically used when sending commands from outside of Opus, to ensure the window that reads the folder is visible. ### Example ```apidoc Go C:\ TOFRONT ``` ``` -------------------------------- ### Get Variable Value with Val Function Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Aval Use Val to retrieve the value of a variable by its name. This is particularly useful for variable names that might conflict with the Evaluator's parser, such as those starting with numbers. ```javascript flag = Val("35mmfocallength"); // get value of the 35mmfocallength field ``` -------------------------------- ### Check, Get, and Set Variables with Persistence (JScript) Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Avars This JScript example mirrors the VBScript functionality, demonstrating how to check for a variable's existence, retrieve its value, set a new value, and enable persistence for it. ```javascript var varName = "MyVariableName"; if (DOpus.Vars.Exists(varName)) { var varValue1 = DOpus.Vars.Get(varName); DOpus.Output(varName + " = " + varValue1); } else { DOpus.Output(varName + " does not exist yet."); } var varValue2 = "My Variable Value"; DOpus.Vars.Set(varName, varValue2); DOpus.Vars(varName).persist = true; ``` -------------------------------- ### CLI QUICKTABS (no value) Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Displays the find-as-you-type field in Tabs mode to search and switch folder tabs. ```cli CLI QUICKTABS ``` -------------------------------- ### Example of Calling a User Command Source: https://docs.dopus.com/doku.php?id=customize%3Athe_customize_dialog%3Auser_commands This demonstrates how a user command, defined with an argument template, can be called from a toolbar button. The provided argument 'txt' is substituted for '&EXT&' in the command's function. ```opus-script Select_Files_Of_Type txt ``` -------------------------------- ### Find Substring Position with InStr Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Ainstr Use InStr to find the starting position of a substring within a string. The function returns the 1-based index of the first occurrence or -1 if the substring is not found. This example demonstrates a basic search. ```dopus_evaluator Output(InStr("The quick brown fox", "quick")) --> 4 ``` -------------------------------- ### CLI QUICKTABS with noselect prefix Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Initializes the find-as-you-type field in Tabs mode with text, placing the cursor at the end. ```cli CLI QUICKTABS noselect:docu ``` -------------------------------- ### CLI QUICKWSLCMD (no value) Example Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Acli Displays the find-as-you-type field in WSL script mode to enter a command for a WSL window. ```cli CLI QUICKWSLCMD ``` -------------------------------- ### Get Translated String with LanguageStr Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Alanguagestr Use LanguageStr to retrieve localized strings for UI elements. This is primarily for default toolbars and may not be necessary for custom scripts. The example shows how to dynamically set a button's label based on a condition. ```dopuscript @label:LanguageStr(selimage ? "CopySelection" : "CopyAll") ``` -------------------------------- ### Install Script Add-in (With File Path) Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Aprefs Launches the Script Installer to install a specified script file. ```dopus Prefs SCRIPTINSTALL /downloads/CoolScript.osp ``` -------------------------------- ### Copy Command Template Example Source: https://docs.dopus.com/doku.php?id=customize%3Acreating_your_own_buttons%3Ainternal_command_arguments This snippet shows the beginning of the Copy command template, illustrating optional arguments, synonyms, and arguments that accept values or keywords. ```text ADDTOARCHIVE=ADDTOZIP/O[,fullpaths,nofullpaths], ARCHIVE=ZIP/O[,single,keepfolder], AS/O, BUFSIZE/K/N, BURNCD/S, CLEARREADONLY/K[yes,no] ``` -------------------------------- ### Install Script Add-in (No Arguments) Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Aprefs Launches the Script Installer to install the currently selected script file. ```dopus Prefs SCRIPTINSTALL ``` -------------------------------- ### Example Script Initialization Data Source: https://docs.dopus.com/doku.php?id=scripting%3Ascript_management%3Anew_script_templates Defines basic initialization parameters for a script, including default enable status and minimum version. ```python initData.url = "https://resource.dopus.com/c/buttons-scripts/16" initData.default_enable = True initData.min_version = "%minver%" initData.shared = %shared% ``` -------------------------------- ### Apply Layout to Current Lister with Paths and Formats Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Aprefs Applies a layout to the current Lister, including its paths, tabs, and folder formats. Use LAYOUTIGNOREFORMATS to override format application. ```command Prefs LAYOUT="CurrentWork" LAYOUTTHISLISTER=pos,size,paths ``` ```command Prefs LAYOUT="My Layout" LAYOUTTHISLISTER=paths LAYOUTIGNOREFORMATS=yes ``` -------------------------------- ### Advanced Rename Evaluator Code Example Source: https://docs.dopus.com/doku.php?id=release_history%3Aopus13_detailed%3Arename Example of using Evaluator code within the New Name field in the Advanced Rename dialog. This specific example extracts a portion of the parent folder name. ```opus-script {=regex(parent, "(.*\\([0-9]{4}\\))", "\1")=} ``` -------------------------------- ### Go USEQUALKEYS Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Ago Activates pre-configured behavior for qualifier keys (Control, Shift, Alt) when navigating folders. ```APIDOC ## Go USEQUALKEYS ### Description Activates pre-configured behavior for the main qualifier keys (Control, Shift, Alt) when navigating folders. ### Example Go C:\ USEQUALKEYS ``` -------------------------------- ### Example FTP Path Source: https://docs.dopus.com/doku.php?id=ftp%3Aftp_paths An example of a full FTP path with username, password, and host. This can be typed into the location field or used in commands. ```plaintext ftp://jon:apple@bigcompany.com/ ``` -------------------------------- ### Get Display Name of a Path Source: https://docs.dopus.com/doku.php?id=reference%3Aevaluator%3Adisplayname Returns the display name of the specified path. Use this to get the user-friendly name of a file or folder. ```dopus_scripting Output(DisplayName("/desktop")); --> Desktop ``` -------------------------------- ### Navigate to Root Folder Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Ago Use Go ROOT to navigate to the root of the current folder. Add the 'collapse' argument to also collapse the current drive's branch in the folder tree. ```go Go ROOT ``` ```go Go ROOT=collapse ``` -------------------------------- ### Show Button if in Opus Install Folder Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Acommand_modifier_reference Use @showifpath with a {apppath} code to control button visibility based on the Opus installation directory. ```opus @showifpath:{apppath|dopus.exe} ``` -------------------------------- ### FSUtil.OpenFile Source: https://docs.dopus.com/doku.php?id=reference%3Ascripting_reference%3Ascripting_objects%3Afsutil Opens or creates a file and returns a File object for binary data access. Checks File.error for success. ```APIDOC ## FSUtil.OpenFile ### Description Opens or creates a file and returns a **File** object that lets you access its contents as binary data. A **File** object is always returned, even if the file could not be opened. Check **File.error** on the returned object immediately after creating it to see if opening the file succeeded. ### Parameters #### Path Parameter - **path** (string or object:Blob) - Required - The file path or Blob object to open. - **mode** (string) - Required - The mode to open the file in (e.g., "r", "w", "a"). - **window** (object) or **elevation** (string) - Optional - Specifies the window or elevation context for opening the file. ### Returns - _object:File_ - A File object representing the opened file. Check **File.error** for success. ``` -------------------------------- ### Anchoring Search to Start of String Source: https://docs.dopus.com/doku.php?id=reference%3Awildcard_reference%3Aregular_expression_syntax The '^' token anchors the regular expression to the beginning of the string. This ensures the pattern only matches if it occurs at the very start. ```regex ^abc ``` -------------------------------- ### Using ADDTOARCHIVE with values Source: https://docs.dopus.com/doku.php?id=customize%3Acreating_your_own_buttons%3Ainternal_command_arguments Demonstrates how to use the ADDTOARCHIVE argument with specific values like 'fullpaths' or 'nofullpaths', and how to combine values with a comma. ```text Copy ADDTOARCHIVE .zip,fullpaths ``` -------------------------------- ### Display Installed VFS Plugins List Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Aprefs Displays a list of installed VFS plugins as a dynamic button. Each plugin has a sub-menu for about, configure, and enable/disable commands. ```dos Prefs VFSPLUGINLIST ``` -------------------------------- ### Go NEW Command with Position and Size Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Ago Specify the position (x, y) and size (width, height) for a new Lister window using the NEW argument. ```opus-script Go NEW 240,300,640,480 ``` -------------------------------- ### Display Installed Printers List Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Ainternal_commands%3Aprint Displays a dynamic list of installed printers, allowing modification of the default printer and printing files by dropping them onto a printer entry. ```dopus Print DEFAULTLIST ``` -------------------------------- ### Copy command with default argument Source: https://docs.dopus.com/doku.php?id=customize%3Acreating_your_own_buttons%3Ainternal_command_arguments Shows an example of the Copy command using a default argument, where the argument name (FILE) is optional. ```text Copy FILE C:\foo.txt TO D:\ ``` ```text Copy C:\foo.txt TO D:\ ``` -------------------------------- ### Boolean Expression Example Source: https://docs.dopus.com/doku.php?id=file_operations%3Afiltered_operations%3Adefining_a_filter Represents a complex filter logic using human-readable Boolean expressions. This example matches .jpg files over 100KB or .gif files under 50KB. ```text match ( name match *.jpg and size match > 100 kb ) or match ( name match *.gif and size match < 50 kb ) ``` -------------------------------- ### Hide Button if in Opus Installation Folder Source: https://docs.dopus.com/doku.php?id=reference%3Acommand_reference%3Acommand_modifier_reference Hides the button if the current source path is within the Opus installation directory. This uses a special code to refer to the application path. ```Opus Script @hideifpath:{apppath|dopus.exe} ```