Move to Number Range Folder
Move a file whose name begins with a number into the corresponding thousand-range folder under $vaultRootFolder\CAD Vault. For example, 2035.docx is moved to CAD Vault\2000-2999. Files already in a matching range folder are left in place.
Warning
This template performs real PDM moves. Review it and test on a small, non-production selection first. It does not create destination folders, check files out, or bypass PDM permissions. Message boxes require an interactive desktop; do not use this version for unattended tasks.
Load and configure
- In PDMShell, open the Script Library and choose Move to Number Range Folder, or download the script.
- Log in to the intended vault. Review
CAD Vaultin the move destination and change it if your vault uses a different base folder. - Create the required range folders in PDM before running, for example
1000-1999,2000-2999, or12000-12999. - Run against selected files, not folders or a no-file run. Merely using
cddoes not select a file for$localPath. - For multiple selections, enable Do not use optimized script execution so each file completes the entire IF/move flow before the next file begins. See execution settings.
This template uses the existing regex and len functions and was tested against PDMShell 4.1.11. It does not require regexReplace, a SOLIDWORKS installation, or a macro.
Script
If ${len(${regex($fileNameWithoutExtension, "^([1-9][0-9]*)[0-9]{3}(?![0-9])", 1)})} = 0 GoTo UnsupportedNumber_1701a374f437
If ${len(${regex($localPath, "(?:^|[\\\\/])(?<n>[1-9][0-9]*)000-\\k<n>999[\\\\/]\\k<n>[0-9]{3}(?![0-9])[^\\\\/]*$", "n")})} = 0 GoTo IfHandler_1701a374f437
msgbox -value "This action cannot be performed on $fileNameWithoutExtension. File is in the correct location." -icon "Information"
GoTo End_IfHandler_1701a374f437
IfHandler_1701a374f437:
move -directory "$vaultRootFolder\CAD Vault\${regex($fileNameWithoutExtension, "^([0-9]+)[0-9]{3}(?![0-9])", 1)}000-${regex($fileNameWithoutExtension, "^([0-9]+)[0-9]{3}(?![0-9])", 1)}999" -source "$localPath"
GoTo End_IfHandler_1701a374f437
UnsupportedNumber_1701a374f437:
msgbox -value "Skipped $fileNameWithoutExtension. Use a file name beginning with a number of at least four digits, without leading zeros." -icon "Information"
End_IfHandler_1701a374f437:
Behavior and limits
| Current path ending | Action |
|---|---|
1000-1999\2035.docx |
Move to CAD Vault\2000-2999. |
2000-2999\2035.docx |
Leave in place and display the correct-location message. |
1000-1999\1035.sldprt |
Leave in place. |
Incoming\12345 drawing.slddrw |
Move to CAD Vault\12000-12999. |
Incoming\Part2035.docx, Incoming\999.docx, or Incoming\02035.docx |
Skip with a message; no move is attempted. |
The first condition is a safety guard added to the supplied template. It prevents unsupported names from producing a 000-999 destination. A supported name begins with a positive number of at least four digits and no leading zeros; suffixes such as 2035 drawing.docx are allowed.
The original location test is preserved: it checks only the immediate parent range folder and the filename number, not the entire base path. A file in Other Area\2000-2999\2035.docx is also considered correctly located and is not moved to CAD Vault. Nested subfolders do not satisfy the immediate-parent check.
Both conditions compare ${len(...)} with 0. This avoids the current IF preprocessing issue where a regex returning empty text can remove an unquoted comparison operand. Keep the backslash escaping exactly as shown; the Script Library JSON adds its own encoding layer automatically. See placeholder expressions and IF statements.
Run a saved copy
Select a file in the visual editor's Run options, or explicitly supply it to runscript:
runscript -source "C:\PDMShellScripts\MOVETONUMBERRANGE.pdmshell" -filePath "C:\SOLIDWORKSPDM\bluebyte\CAD Vault\1000-1999\2035.docx"
Replace these example paths with your saved script and actual vault view. The example moves the file if permitted and the destination exists. Review the command output for failures; the template does not claim a move succeeded or roll back earlier moves in a batch.