Please read this entire post before proceeding!
SYSTEM REQUIREMENTS:
This user command has been stress tested in Windows XP. But it should work right away in Windows Vista, and possibly Windows 2000 (it may require rework for Windows 2000).
If you have one of these operating systems, try out the button in an empty test folder, before using it in one of your production folders. It would be great if someone with Windows 2000 would post back with results.
NOTE: This User Command is not supported in Windows/95/98/ME/NT.
USER COMMAND:
CreateNumberedFolders - User Command
This user command allows you to create several numbered folders with the same base name. CreateNumberedFolders is actually a NT command script that accepts some Opus command options, provides logic branching, and asks Opus to perform some tasks. The command template is:
BASENAME/K/A, FROM/K, TO/K/A, BY/K, WAITINTERVAL/K[ul][li]BASENAME/K/A - The base name of the folder ("New Folder - " in the example command below). Include any desired divider character between the base name and the number as part of the base name itself.
[/li]
[li]FROM/K - The starting number for the first folder. Add leading zeroes to this value, if you wish to pad shorter numbers to a certain number of characters. Thus, FROM=0025 would number the first folder 0025 and ensure that all numbers would be padded to four digits using leading zeroes when necessary. If this option is omitted, the command assumes a default of 1 and no padding with leading zeroes.
[/li]
[li]TO/K/A - The highest number folder created. The command has been stress tested to 10,000 folders and it should handle more if required.
[/li]
[li]BY/K - Use this option to specify the increment used between successive folder numbers, starting with the number specified in the TO option. Thus BY=10 would number folders by 10 instead of the default of numbering them by 1.
[/li]
[li]WAITINTERVAL/K - There are a couple of places where the script must wait for Opus to finish its operation or update its file list, before the script can progress safely to its next command. Otherwise, the script and Opus will be in a race condition, where the script expects all folders to be created or selected but the file listing hasn't been updated yet.
I have stress tested this command for as few as 1 and as many as 10,000 folders using the default wait interval of 3 seconds. However, I cannot anticipate what else may be running on your system. Should you experience errors in your folder names, try increasing WAITINTERVAL. You could also try a smaller value, but this is not recommended.
Character Limitations in folder names:
For performance reasons CreateNumberedFolders uses the Command Prompt command MakeDir to create its folders, rather than the Opus CREATEFOLDER command (stress testing has proven MakeDir is much faster). As a result, folder names are limited to those characters supported by the MakeDir command and NT Command scripts. (In general, Windows XP is more liberal in what characters may be used.)
Directory Opus also has an issue (that I discovered when scripting this command) when selecting folders or files by pattern, if the name contains the "~" character. If you use a base name with this character, the folders will be created, but they will not have the names you expect. This is also due in part to a separate Opus issue that I needed to script around.
IMPORTANT: Using this command from within Windows Namespace folders, like My Computer, will result in errors and is strongly not advised![/li][/ul]
USAGE EXAMPLES: (All Usage Examples are included in the .zip download file.)
-
Create 10 folders numbered from 10 to 100 by 10 and padding all numbers to three digits.
CreateNumberedFolders BASENAME="New Folder - " FROM=010 TO=100 BY=10 WAITINTERVAL=2
The output of this command is:
New Folder - 010 New Folder - 020 New Folder - 030 New Folder - 040 New Folder - 050 New Folder - 060 New Folder - 070 New Folder - 080 New Folder - 090 New Folder - 100
-
Create multiple numbered folders with same base name. Default the base name to "New Folder - ", the numbering from 10 to 100 by 10, and number padding to three digits. Prompt the user to override each value before executing.
Runmode Hide dopusrt /CMD CreateNumberedFolders BASENAME="{dlgstring|Enter base name for all folders:|New Folder - |}" FROM={dlgstring|Enter starting number (pad with leading zeroes if padding is desired):|010} TO={dlgstring|Enter highest number:|100} BY={dlgstring|Enter amount to increment folder numbers by:|10}
The default output of this command is the same as that of example 1. above; however, the user may override the option values on-the-fly.
RELEASE NOTES:
[ul][li] Version 1.2 - Modified the User Command script to allow toolbar buttons to utilize dopusrt /CMD syntax. This syntax allows the user to create a button that will prompt for all required option values. Such a button is more practical for creating folders on-the-fly. A sample button that makes use of this syntax is included in the .zip download file.
[/li]
[li] Version 1.0 - Original download file (unversioned).[/li][/ul]
HOW TO CORRECTLY GET THE COMMAND TO YOUR DIRECTORY OPUS CONFIGURATION:[ol][li] Download the attached .zip file and extract it to a folder.[/li]
[li] List the folder in an Opus lister.[/li]
[li] Right-click any Opus toolbar and select Customize.[/li]
[li] Click on the Customize > Commands Tab.[/li]
[li] Click on the User Category.[/li]
[li] Drag CreateNumberedFolders-UserCommand.dcf to the User Commands list.[/li]
[li] From the User Commands list, drag the command to any toolbar and edit its options to suit your needs.[/li][/ol]
Remember CreateNumberedFolders is a User Command not a Toolbar Button!
The CreateNumberedFolders command code is structured differently from most other toolbar buttons. User Commands differ greatly from Toolbar buttons. For instance, once a User Command is created, it can be used from inside other Toolbar Buttons. If its template is configured correctly, any qualified options for a user command will be displayed in its Arguments List in the Advanced Command Editor.
When Directory Opus User Commands are exported to a Directory Opus Command (*.dcf) files, they appear very much like exported Toolbar Buttons. User Commands, that do not utilize a Command Template, can be exported to a *.dcf file and subsequently dragged directly to a Directory Opus toolbar to create a Toolbar Button without actually creating the related User Command.
IMPORTANT: User Commands that do utilize a Command Template (like CreateNumberedFolders) cannot be directly dragged to a toolbar--doing so will create a Toolbar Button with no Command Template, breaking the intended functionality of the user command.
I hope you find this useful and educational
CreateNumberedFolders-v1.2.zip (6.47 KB)