Pascal Script: Overview
TODOTODO: Review if anything is missing from the original article.
The Pascal Script rule in ReNamer allows advanced users to create custom renaming logic using a scripting language based on Pascal/Delphi syntax. This provides full programmatic control over filenames, paths, metadata, and file system operations, making it ideal for complex tasks that standard rules cannot handle easily.
A collection of specialized functions and extensions makes scripting particularly powerful for Unicode filename handling, dynamic meta tag extraction, file system interactions, and integrating external data or tools.
Key concepts
FileName variable of type WideString, which represents the new basename with extension. Modify this variable to change the new name for a file.
Path Access: The FilePath constant provides the full original path to the file, allowing direct file system operations, like reading content, applying external tools, etc.
Unicode Support: ReNamer's implementation uses WideString as the primary string type for full Unicode compatibility, supporting non-English characters and international scripts.
Extensions and functions
ReNamer extends the standard Pascal Script engine with custom types and functions tailored for renaming tasks, including:
WideUpperCase, WideReplaceStr.
File utilities, e.g. WideFileExists, FileReadTextLines.
Meta tag extraction via CalculateMetaTag.
Support for user-defined functions (UDFs) and importing external functions from DLLs.
Include directive {$INCLUDE 'filename.inc'} for reusing code from external files (available since v6.5.0.1 Beta).
Best practices
Follow these recommendations for reliable, efficient scripts:
WideString over String for paths and names to ensure Unicode compatibility.
Avoid overriding built-in variables, types, or functions.
Some functions can modify the file system (e.g. create folders, delete files), use these with caution.
Test scripts thoroughly in Preview mode.
Warnings:
Further reading
You can also find examples, discussions and user contributed scripts on the User Forum.