Pascal Script: Functions
TODO: Review, update links.
This page provides a complete reference of all functions available in Pascal Script within ReNamer, organized by category.
A function generally performs some work, it may take some input parameters, and may produce or return some output. Functions that do no return anything are also known as procedures.
In this document, functions have the following general signature: FunctionName (Parameters): ReturnType, where the parameters and the return type vary by function.
Parameters to function may have prefixes indicating how they're used:
const— Value is read-only and cannot be modified.var— Value can be modified by the function and changes are returned.out— Variable receives output from the function.
A common "Wide" prefix in function names indicates that the function works with WideString type for full Unicode support, rather than String or AnsiString type. For example, ShowMessage vs WideShowMessage. See String Types for more information.
Basic String Handling
| Function | Description |
|---|---|
Insert (Source: String; var S: String; Index: Integer) |
Inserts the string S into string Source at position Index. |
Delete (var S: String; Index, Count: Integer) |
Deletes Count characters from the string S, starting from position Index. |
Copy (S: String; Index, Count: Integer): String |
Copies Count characters from string S, starting at position Index, and returns them as a new string. |
Pos (Substr: String; S: String): Integer |
Returns the position of string Substr in string S. Returns 0 if not found. |
Note: String indexes are 1-based, so the first character in string S is S[1].
Length Management
| Function | Description |
|---|---|
SetLength (var S: Array; NewLength: Integer) |
Sets the length of array variable S to NewLength. |
SetLength (var S: String; NewLength: Integer) |
Sets the length of string variable S to NewLength. |
SetLength (var S: WideString; NewLength: Integer) |
Sets the length of WideString S to NewLength. |
Length (const S: Array): Integer |
Returns the length of array S (number of elements). |
Length (const S: String): Integer |
Returns the length of string S (number of characters). |
Length (const S: WideString): Integer |
Returns the length of WideString S (number of characters). |
Wide String Handling
| Function | Description |
|---|---|
WideInsert (const Substr: WideString; var Dest: WideString; Index: Integer) |
Inserts Substr in Dest at position Index. |
WideDelete (var S: WideString; Index, Count: Integer) |
Deletes Count characters from S, starting from position Index. |
WideDeleteRight (var S: WideString; Index, Count: Integer) |
Deletes Count characters from S, starting from position Index from the end and counting towards the start.Added in v6.0.0.9 Alpha. |
WideSetLength (var S: WideString; NewLength: Integer) |
Changes the length of string S to NewLength. If the new length is smaller than the original, the string is truncated. If the new length is larger, the string is expanded but the additional characters will be uninitialized and may contain random data. |
WideLength (const S: WideString): Integer |
Returns the length of WideString S. |
WideCopy (const S: WideString; Index, Count: Integer): WideString |
Returns Count characters from S, starting at position Index. |
WideCopyRight (const S: WideString; Index, Count: Integer): WideString |
Returns Count characters from S, starting at position Index from the end and counting towards the start.Added in v6.0.0.9 Alpha. |
WidePos (const SubStr, S: WideString): Integer |
Finds an occurrence of SubStr in S. Returns the position of first occurrence, or 0 if not found. |
WidePosEx (const SubStr, S: WideString; Offset: Cardinal): Integer |
Finds an occurrence of SubStr in S starting from position Offset. Returns the position of first occurrence, or 0 if not found. |
WideUpperCase (const S: WideString): WideString |
Returns the uppercase version of WideString S. |
WideLowerCase (const S: WideString): WideString |
Returns the lowercase version of WideString S. |
WideCompareStr (const S1, S2: WideString): Integer |
Compares two WideStrings case-sensitively. Returns a value less than 0 if S1 < S2, 0 if S1 = S2, or greater than 0 if S1 > S2. |
WideCompareText (const S1, S2: WideString): Integer |
Compares two WideStrings case-insensitively. Returns a value less than 0 if S1 < S2, 0 if S1 = S2, or greater than 0 if S1 > S2. |
WideSameText (const S1, S2: WideString): Boolean |
Compares two WideStrings case-insensitively. Returns True if identical, otherwise False. |
WideTextPos (const SubStr, S: WideString): Integer |
Like WidePos but case-insensitive. |
WideTextPosEx (const SubStr, S: WideString; Offset: Cardinal): Integer |
Like WidePosEx but case-insensitive.Added in v6.6.0.1 Beta. |
WideTrim (const S: WideString): WideString |
Removes leading and trailing spaces and control characters from string S. |
WideTrimChars (const S, CharsToTrim: WideString): WideString |
Removes characters in CharsToTrim from the beginning and end of S.Added in v6.0.0.9 Alpha. |
WideTrimCharsLeft (const S, CharsToTrim: WideString): WideString |
Removes characters in CharsToTrim from the beginning of S.Added in v6.0.0.9 Alpha. |
WideTrimCharsRight (const S, CharsToTrim: WideString): WideString |
Removes characters in CharsToTrim from the end of S.Added in v6.0.0.9 Alpha. |
WideReverseString (const S: WideString): WideString |
Returns a reversed version of string S.Added in v6.7.0.4 Beta. |
WideRepeatString (const S: WideString; Count: Integer): WideString |
Repeats string S the specified number of times.Added in v6.9.0.3 Beta. |
WideReplaceStr (const S, OldPattern, NewPattern: WideString): WideString |
Replaces all case-sensitive occurrences of OldPattern with NewPattern in string S. |
WideReplaceText (const S, OldPattern, NewPattern: WideString): WideString |
Replaces all case-insensitive occurrences of OldPattern with NewPattern in string S. |
WideSplitString (const Input, Delimiter: WideString): TWideStringArray |
Splits Input wherever Delimiter occurs and returns an array of the split parts. The Delimiter can be a multi-character string (not limited to single characters like comma or space). The returned parts do not include the delimiter. |
WideJoinStrings (const Strings: TWideStringArray; const Delimiter: WideString): WideString |
Joins all items from Strings into a single WideString, with Delimiter inserted between items. |
WideCaseSentence (const S: WideString): WideString |
Returns sentence case version of S. Only the first alphabetic character is capitalized, all others are lowercase.Added in v6.0.0.3 Alpha. |
WideCaseCapitalize (const S: WideString): WideString |
Returns title case version of S. First letter of every word is capitalized, all others are lowercase. |
WideCaseInvert (const S: WideString): WideString |
Inverts the case of all characters in S. |
Wide String Array Handling
| Function | Description |
|---|---|
WideAppendStringArray (var Strings: TWideStringArray; const NewString: WideString) |
Adds a WideString to the end of a WideString array. Added in v7.5.0.3 Beta. |
WideCopyStringArray (const Strings: TWideStringArray; Index, Count: Integer): TWideStringArray |
Copies a portion of a WideString array by taking Count elements starting from Index position.Added in v7.5.0.3 Beta. |
WideConcatStringArrays (const A, B: TWideStringArray): TWideStringArray |
Concatenates two WideString arrays. Added in v7.5.0.3 Beta. |
Wide Character Handling
| Function | Description |
|---|---|
IsWideCharUpper (WC: WideChar): Boolean |
Checks if character WC is uppercase. |
IsWideCharLower (WC: WideChar): Boolean |
Checks if character WC is lowercase. |
IsWideCharDigit (WC: WideChar): Boolean |
Checks if character WC is a digit (0-9). |
IsWideCharSpace (WC: WideChar): Boolean |
Checks if character WC is whitespace (space, tab, newline, etc.). |
IsWideCharPunct (WC: WideChar): Boolean |
Checks if character WC is a punctuation mark. |
IsWideCharCntrl (WC: WideChar): Boolean |
Checks if character WC is a control character. |
IsWideCharBlank (WC: WideChar): Boolean |
Checks if character WC is blank (space or tab). |
IsWideCharXDigit (WC: WideChar): Boolean |
Checks if character WC is a hexadecimal digit (0-9, A-F). |
IsWideCharAlpha (WC: WideChar): Boolean |
Checks if character WC is alphabetic (a-z, A-Z). |
IsWideCharAlphaNumeric (WC: WideChar): Boolean |
Checks if character WC is alphanumeric (a-z, A-Z, 0-9). |
IsWideWordBoundaryLeft (const Subject: WideString; CharPosition: Integer): Boolean |
Checks if a character at the specified position is on a word boundary to the left. Added in v6.6.0.1 Beta. |
IsWideWordBoundaryRight (const Subject: WideString; CharPosition: Integer): Boolean |
Checks if a character at the specified position is on a word boundary to the right. Added in v6.6.0.1 Beta. |
WideCharUpper (const WC: WideChar): WideChar |
Returns uppercase version of the character. Non-alphabetic characters are returned unchanged. |
WideCharLower (const WC: WideChar): WideChar |
Returns lowercase version of the character. Non-alphabetic characters are returned unchanged. |
WideChr (Code: Word): WideChar |
Creates a character from a Unicode code point. Added in v6.9.0.3 Beta. |
Note: Character classifications (C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA) are part of Unicode definitions. More information can be found at fileformat.info.
Unicode Conversion
| Function | Description |
|---|---|
WideToAnsi (const WS: WideString): String |
Converts WideString to AnsiString. In v7.0 and later, this conversion happens automatically on assignment. |
AnsiToWide (const S: String): WideString |
Converts AnsiString to WideString. In v7.0 and later, this conversion happens automatically on assignment. |
UTF8Encode (const WS: WideString): String |
Converts WideString to UTF-8 encoded string. |
UTF8Decode (const S: String): WideString |
Converts UTF-8 encoded string to WideString. |
WinCPToUTF8 (const S: String): String |
Converts a string encoded with active system code page to UTF-8. Added in v7.4.0.3 Beta. |
UTF8ToWinCP (const S: String): String |
Converts UTF-8 encoded string to a string encoded with active system code page. Added in v7.4.0.3 Beta. |
See String Types for additional information on default encoding and conversion procedures.
Console Output Conversion
OEM-defined character set is commonly used in console application output.
| Function | Description |
|---|---|
OemToAnsi (const S: String): String |
Converts OEM string to ANSI string. Added in v6.6.0.2 Beta. |
OemToWide (const S: String): WideString |
Converts OEM string to WideString. Added in v6.6.0.2 Beta. |
AnsiToOem (const S: String): String |
Converts ANSI string to OEM string. Added in v6.6.0.2 Beta. |
WideToOem (const S: WideString): String |
Converts WideString to OEM string. Added in v6.6.0.2 Beta. |
Basic Conversion
| Function | Description |
|---|---|
BoolToStr (B: Boolean): String |
Converts boolean value to string. Returns "True" or "False". |
IntToStr (Value: Integer): String |
Converts an integer to string. Warning: Be cautious when passing Int64 values. They will be automatically type cast to Integer, which significantly reduces the range of possible values (see Types for details). For Int64 values, use Int64ToStr or FormatFloat to avoid range loss. |
Int64ToStr (Value: Int64): String |
Converts an Int64 value to string. |
StrToInt (const S: String): Integer |
Converts a string to integer. Raises an error if conversion fails. |
StrToInt64 (const S: String): Int64 |
Converts a string to Int64. Raises an error if conversion fails. |
StrToIntDef (const S: String; const Default: Integer): Integer |
Converts a string to integer. Returns Default value if conversion fails. |
StrToInt64Def (const S: String; Default: Int64): Int64 |
Converts a string to Int64. Returns Default value if conversion fails. |
TryStrToInt (const S: String; out Value: Integer): Boolean |
Converts a string to integer. Returns False if conversion fails instead of raising an error. |
FloatToStr (Value: Extended): String |
Converts floating point value to string using default system format. |
StrToFloat (const S: String): Extended |
Converts string to floating point value. Raises an error if conversion fails. |
StrToFloatDef (const S: String; const Default: Extended): Extended |
Converts string to floating point value. Returns Default value if conversion fails. |
FormatFloat (const Format: String; Value: Extended): String |
Converts floating point value to string using custom format. See floating point format specifiers below. |
DateToStr (D: TDateTime): String |
Converts date to string using system short date format (e.g., dd/mm/yyyy). |
StrToDate (const S: String): TDateTime |
Converts date string to TDateTime using system short date format (e.g., dd/mm/yyyy). |
IntToHex (Value: Integer; Digits: Integer): String |
Converts integer to hexadecimal representation. Digits specifies minimum number of digits (padded with zeros). |
HexToInt (const HexNum: String): Integer |
Converts hexadecimal string to integer. Raises an error if conversion fails. |
HexToIntDef (const HexNum: String; Default: Integer): Integer |
Converts hexadecimal string to integer. Returns Default value if conversion fails. |
IntToRoman (Value: Integer): String |
Converts decimal number to Roman numerals. Added in v7.3.0.4 Beta. |
RomanToInt (const S: String): Integer |
Converts Roman numerals to decimal number. Added in v7.3.0.4 Beta. |
RomanToIntDef (const S: String; Default: Integer): Integer |
Converts Roman numerals to decimal number. Returns Default if conversion fails.Added in v7.3.0.4 Beta. |
TryRomanToInt (const S: String; out Value: Integer): Boolean |
Converts Roman numerals to decimal number. Returns False if conversion fails instead of raising an error.Added in v7.3.0.4 Beta. |
Ord (X: Char): Byte |
Returns ordinal value (byte representation) of a character. |
Chr (X: Byte): Char |
Returns a character from its ordinal value (byte representation). |
Floating point format specifiers
| Specifier | Description |
|---|---|
0 (zero) |
Digit placeholder. If a digit exists in this position, it's copied to output; otherwise a "0" is inserted. |
# (hash) |
Digit placeholder. If a digit exists in this position, it's copied to output; otherwise nothing is inserted. |
. (dot) |
Decimal point. The first "." determines the decimal separator location. Additional "." characters are ignored. |
, (comma) |
Thousand separator. Inserts separators between each group of three digits to the left of the decimal point. |
Date and Time
| Function | Description |
|---|---|
Date: TDateTime |
Returns the current system date. |
Time: TDateTime |
Returns the current system time. |
Now: TDateTime |
Returns the current system date and time. |
EncodeDate (Year, Month, Day: Word): TDateTime |
Creates a date value from year, month, and day components. Valid ranges: Year = 0..9999, Month = 1..12, Day = 1..31. Raises an error if parameters are invalid. |
EncodeTime (Hour, Min, Sec, MSec: Word): TDateTime |
Creates a time value from hour, minute, second, and millisecond components. Valid ranges: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. Raises an error if parameters are invalid. |
EncodeDateTime (Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime |
Creates a date-time value from date and time components. Similar to combining EncodeDate and EncodeTime.Added in v6.2.0.5 Beta. |
TryEncodeDate (Year, Month, Day: Word; var Date: TDateTime): Boolean |
Like EncodeDate but returns True/False instead of raising an error. |
TryEncodeTime (Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean |
Like EncodeTime but returns True/False instead of raising an error. |
TryEncodeDateTime (Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean |
Like EncodeDateTime but returns True/False instead of raising an error.Added in v6.2.0.5 Beta. |
DecodeDate (const DateTime: TDateTime; var Year, Month, Day: Word) |
Extracts year, month, and day components from a TDateTime value. |
DecodeTime (const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word) |
Extracts hour, minute, second, and millisecond components from a TDateTime value. |
DecodeDateTime (const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word) |
Extracts both date and time components from a TDateTime value. Added in v6.2.0.5 Beta. |
ComposeDateTime (const Date, Time: TDateTime): TDateTime |
Combines separate date and time values into a single TDateTime value. Added in v6.2.0.5 Beta. |
DateTimeToUnix (D: TDateTime): Int64 |
Converts TDateTime value to Unix timestamp. |
UnixToDateTime (U: Int64): TDateTime |
Converts Unix timestamp to TDateTime value. |
FormatDateTime (const Format: String; DateTime: TDateTime): String |
Converts date and time to string using custom Date and Time formatting. |
ScanDateTime (const Pattern, Subject: String): TDateTime |
Parses a date/time string according to a Date and Time format pattern. Added in v7.1.0.3 Beta. |
TryScanDateTime (const Pattern, Subject: String; out DateTime: TDateTime): Boolean |
Like ScanDateTime but returns True/False instead of raising an error.Added in v7.1.0.3 Beta. |
IncYear (const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime |
Adds or subtracts years from a TDateTime value. |
IncMonth (const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime |
Adds or subtracts months from a TDateTime value. |
IncWeek (const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime |
Adds or subtracts weeks from a TDateTime value. |
IncDay (const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime |
Adds or subtracts days from a TDateTime value. |
IncHour (const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime |
Adds or subtracts hours from a TDateTime value. |
IncMinute (const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime |
Adds or subtracts minutes from a TDateTime value. |
IncSecond (const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime |
Adds or subtracts seconds from a TDateTime value. |
IncMilliSecond (const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime |
Adds or subtracts milliseconds from a TDateTime value. |
SecondSpan (const ANow, AThen: TDateTime): Double |
Calculates approximate number of seconds between two date-time values. Added in v6.2.0.5 Beta. |
DayOfWeek (const DateTime: TDateTime): Word |
Returns day number of the week (1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday, 7=Sunday). Before v6.1 this function returned 1=Sunday to 7=Saturday. |
DayOfMonth (const DateTime: TDateTime): Word |
Returns the day number of the month. Added in v6.1. |
DayOfYear (const DateTime: TDateTime): Word |
Returns the day number of the year. Added in v6.1. |
WeekOfMonth (const DateTime: TDateTime): Word |
Returns the week number of the month. Added in v6.1. |
WeekOfYear (const DateTime: TDateTime): Word |
Returns the week number of the year. Added in v6.1. |
File Management
| Function | Description |
|---|---|
WideFileSize (const FileName: WideString): Int64 |
Returns file size in bytes. Returns -1 if file does not exist. |
WideFileExists (const FileName: WideString): Boolean |
Checks if specified file exists. |
WideDirectoryExists (const Directory: WideString): Boolean |
Checks if specified directory exists. |
WideForceDirectories (const Dir: WideString): Boolean |
Ensures all directories in the path exist, creating them recursively if needed. Returns True if successful. |
WideCreateDir (const Dir: WideString): Boolean |
Creates specified directory (non-recursive). Returns True on success. |
WideRemoveDir (const Dir: WideString): Boolean |
Removes a directory if it is empty. Returns True on success.Added in v6.4.0.1 Beta. |
WideDeleteFile (const FileName: WideString): Boolean |
Deletes file from disk. Returns True on success. |
WideDeleteToRecycleBin (const FileName: WideString): Boolean |
Moves file or folder to Recycle Bin. Returns True on success. Full path must be provided.Added in v6.4.0.1 Beta. |
WideRenameFile (const OldName, NewName: WideString): Boolean |
Renames file from OldName to NewName. Returns True on success. |
WideCopyFile (const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean |
Copies file from FromFile to ToFile. If FailIfExists is True, operation fails when destination exists; otherwise destination is overwritten. Returns True on success. |
WideFileSearch (const Name, DirList: WideString): WideString |
Searches for a file named Name in directories listed in DirList (semicolon-delimited). Returns full path if found, empty string otherwise. |
WideScanDirForFiles (const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString) |
Scans a directory for files and returns the list in the Files array.• Dir — Directory to scan• Files — Array to receive the file list• Recursive — Scan subdirectories• IncludeHidden — Include hidden files• IncludeSystem — Include system files• Mask — Wildcard mask to filter files, or empty string for all files |
WideScanDirForFolders (const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean) |
Scans a directory for folders and returns the list in the Folders array.• Dir — Directory to scan• Folders — Array to receive the folder list• Recursive — Scan subdirectories• IncludeHidden — Include hidden folders• IncludeSystem — Include system folders |
File Name Utilities
| Function | Description |
|---|---|
WideExtractFilePath (const FileName: WideString): WideString |
Returns drive and directory portion with trailing path delimiter (e.g., "C:\Folder\"). |
WideExtractFileDir (const FileName: WideString): WideString |
Returns drive and directory portion without trailing path delimiter (e.g., "C:\Folder"). |
WideExtractFileDrive (const FileName: WideString): WideString |
Returns the drive letter (e.g., "C:"). |
WideExtractFileName (const FileName: WideString): WideString |
Returns filename with extension (e.g., "Document.txt"). |
WideExtractBaseName (const FileName: WideString): WideString |
Returns filename without extension or path (e.g., "Document.txt" → "Document"). |
WideExtractFileExt (const FileName: WideString): WideString |
Returns file extension with dot (e.g., ".txt"). |
WideChangeFileExt (const FileName, Extension: WideString): WideString |
Replaces file extension (e.g., "File.txt" → "File.pdf"). |
WideStripExtension (const FileName: WideString): WideString |
Removes extension while preserving path (e.g., "C:\Folder\Document.txt" → "C:\Folder\Document"). |
WideExpandFileName (const FileName: WideString): WideString |
Converts relative filename to fully qualified path. Does not verify file existence. |
WideExtractRelativePath (const BaseName, DestName: WideString): WideString |
Creates relative path from BaseName to DestName (e.g., "C:\Folder\File.txt" to "C:\Documents\Article.pdf" returns "..\Documents\Article.pdf"). |
WideExtractShortPathName (const FileName: WideString): WideString |
Converts path to DOS 8.3 format. |
WideIncludeTrailingPathDelimiter (const S: WideString): WideString |
Ensures path ends with path delimiter ("\"). |
WideExcludeTrailingPathDelimiter (const S: WideString): WideString |
Ensures path does not end with path delimiter ("\"). |
WideSameFileName (const FileName1, FileName2: WideString): Boolean |
Compares filenames for equality (case-insensitive on Windows). Added in v6.7.0.4 Beta. |
WideMatchesMask (const FileName, Mask: WideString): Boolean |
Checks if filename matches wildcard mask (e.g., "*.txt"). Added in v6.7.0.4 Beta. |
WideMatchesMaskList (const FileName, MaskList: WideString): Boolean |
Checks if filename matches any wildcard mask in semicolon-separated list (e.g., ".txt;.doc"). Added in v6.7.0.4 Beta. |
File Read/Write
| Function | Description |
|---|---|
FileReadFragment (const FileName: WideString; Start, Length: Integer): String |
Reads Length characters from file starting at position Start (0-based). |
FileReadLines (const FileName: WideString): TAnsiStringArray |
Reads all lines from a file and returns as array. Added in v5.74.4 Beta. |
FileReadLine (const FileName: WideString; LineNum: Integer): String |
Reads a specific line from file by line number (1-based). Note: This function is extremely inefficient and provided only for convenience. Avoid using it in loops. |
FileCountLines (const FileName: WideString): Integer |
Counts the number of lines in a file. Note: This function is extremely inefficient and provided only for convenience. Avoid using it repeatedly. |
FileReadContent (const FileName: WideString): String |
Returns entire file content as a string. |
FileWriteContent (const FileName: WideString; const Content: String) |
Writes content to file, overwriting if file exists. |
FileAppendContent (const FileName: WideString; const Content: String) |
Appends content to end of file, creating file if it doesn't exist. |
FileReadText (const FileName: WideString): WideString |
Reads text from file with automatic encoding detection. Added in v6.6.0.6 Beta. |
FileReadTextLines (const FileName: WideString): TWideStringArray |
Reads text lines from file with automatic encoding detection. Added in v6.7.0.1 Beta. |
Note: Automatic encoding detection is based on byte order mark (BOM) and supports UTF-8, UTF-16BE, and UTF-16LE. Files without BOM are interpreted as ANSI encoding.
File Time
| Function | Description |
|---|---|
FileTimeModified (const FileName: WideString): TDateTime |
Returns last modified time of file. |
FileTimeCreated (const FileName: WideString): TDateTime |
Returns creation time of file. |
SetFileTimeCreated (const FileName: WideString; const DateTime: TDateTime): Boolean |
Sets creation time of file. |
SetFileTimeModified (const FileName: WideString; const DateTime: TDateTime): Boolean |
Sets last modified time of file. |
Meta Tags Extraction
| Function | Description |
|---|---|
CalculateMetaTag (const FilePath: WideString; const MetaTagName: String): WideString |
Extracts meta tag value from file. Requires full absolute path. Return type changed from String to WideString in v5.74.4 Beta. |
CalculateMetaTagFormat (const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString |
Same as CalculateMetaTag but with custom date/time format.Added in v5.74.4 Beta. |
Example usage:
begin
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');
end.
The full list of meta tags can be found in the Meta Tags article. For date/time formatting see Date and Time format article.
Regular Expressions
| Function | Description |
|---|---|
IsMatchingRegEx (const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean |
Checks if input matches a regular expression pattern. Added in v5.74.4 Beta. |
ReplaceRegEx (const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString |
Finds and replaces all regex pattern matches. Works like the Regular Expressions rule. • Input — Original subject text• Find — Search pattern• Replace — Replacement pattern• CaseSensitive — Search in case-sensitive mode• UseSubstitution — Substitute backreferences in replacement pattern |
FindRegEx (const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer |
Finds all matches and positions of a regex pattern. Returns the number of matches found. • Input — Original subject text• Find — Search pattern• CaseSensitive — Search in case-sensitive mode• Positions — Receives positions where matches were found• Matches — Receives the matched stringsAdded in v7.3.0.4 Beta. |
MatchesRegEx (const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray |
Returns array of full regex matches (not sub-patterns). |
SubMatchesRegEx (const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray |
Returns array of sub-expression matches for the first full match. Can be combined with MatchesRegEx to parse individual sub-expressions. |
Example matches for MatchesRegEx and SubMatchesRegEx:
| Input | Pattern | Matches | SubMatches |
|---|---|---|---|
| A1_B2_C3 | [A-Z]\d |
A1, B2, C3 | (empty) |
| A1_B2_C3 | ([A-Z])(\d) |
A1, B2, C3 | A, 1 |
Process Execution
| Function | Description |
|---|---|
ShellOpenFile (const FileName: WideString): Boolean |
Opens a file with its associated application. Works like "Start > Run". The parameter can be a file path, URL, or any registered protocol. Warning: This function evaluates the command and may produce unexpected results. For example, ShellOpenFile('notepad') could run the Windows Notepad from C:\Windows\notepad.exe, a different notepad.exe found in the PATH environment variable, or even open a folder named "notepad" in the current directory. |
ExecuteProgram (const Command: String; WaitForProgram: Boolean): Cardinal |
Executes a command. WaitForProgram controls whether to wait for completion. Returns exit code. |
ExecuteProgramShow (const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal |
Executes a command with control over window visibility. Returns exit code. • Command — Command to execute• WaitForProgram — Wait for program to finish before continuing• ShowWindowFlag — Window display mode:◦ 0 = Hide window ◦ 1 = Normal (activate and display) ◦ 2 = Minimized (activate) ◦ 3 = Maximized (activate) ◦ 4 = Show without activating ◦ 7 = Minimized without activating Added in v5.75.3 Beta. |
ExecConsoleApp (const CommandLine: String; out Output: String): Cardinal |
Executes a console application and captures its standard output in the Output variable. Returns the exit code.Console applications use OEM encoding by default unless they change their own output code page. Use OemToAnsi or OemToWide functions to convert the output if needed.Prior to v6.6.0.2 Beta, OEM to ANSI conversion was applied automatically. Since v6.6.0.2 Beta, output is returned unmodified to prevent corruption of binary or non-OEM encoded data. |
Dialogs
| Function | Description |
|---|---|
ShowMessage (const Msg: String) |
Shows message dialog with OK button. |
WideShowMessage (const Msg: WideString) |
Shows message dialog with Unicode text support. |
DialogYesNo (const Msg: String): Boolean |
Shows Yes/No dialog. Returns True if user clicks Yes. |
WideDialogYesNo (const Msg: WideString): Boolean |
Shows Yes/No dialog with Unicode text support. |
InputBox (const ACaption, APrompt, ADefault: String): String |
Shows input dialog with text box. Returns entered value or default if user cancels. |
InputQuery (const ACaption, APrompt: String; var Value: String): Boolean |
Shows input dialog. Returns True if user clicks OK. Entered value is stored in Value parameter. |
WideInputBox (const ACaption, APrompt, ADefault: WideString): WideString |
Shows input dialog with Unicode text support. |
WideInputQuery (const ACaption, APrompt: WideString; var Value: WideString): Boolean |
Shows input dialog with Unicode text support and Boolean return value. |
Application
| Function | Description |
|---|---|
GetApplicationPath: WideString |
Returns full path to ReNamer executable. |
GetApplicationParams: TWideStringArray |
Returns array of command line parameters passed to application. |
GetCurrentFileIndex: Integer |
Returns index of current file being processed (1 to GetTotalNumberOfFiles). |
GetTotalNumberOfFiles: Integer |
Returns total number of files in the list. |
GetCurrentMarkedFileIndex: Integer |
Returns index of current file among marked files only (1 to GetTotalNumberOfMarkedFiles). |
GetTotalNumberOfMarkedFiles: Integer |
Returns total number of marked files. |
GetAllFiles: TWideStringArray |
Returns file paths of all files in the list. Added in v5.74.2 Beta. |
GetMarkedFiles: TWideStringArray |
Returns file paths of all marked files. Added in v5.74.2 Beta. |
Global Variables
Global variables allow efficient storage and exchange of information between script executions.
Variables persist until manually cleared or application terminates. To clear variables at each preview, use script initialization.
Added in v7.4.0.2 Beta.
| Function | Description |
|---|---|
SetGlobalVar (const Name: String; Value: Variant) |
Sets a global variable. |
GetGlobalVar (const Name: String): Variant |
Gets a global variable. Returns Unassigned if variable doesn't exist. |
GetGlobalVarDef (const Name: String; Default: Variant): Variant |
Gets a global variable. Returns a default value if variable doesn't exist. |
HasGlobalVar (const Name: String): Boolean |
Checks if a global variable exists. |
GetGlobalVarCount: Integer |
Returns total number of global variables. |
GetGlobalVarNames: TAnsiStringArray |
Returns names of all global variables. |
ClearGlobalVar (const Name: String) |
Clears a specific global variable. |
ClearGlobalVars |
Clears all global variables. |
System
| Function | Description |
|---|---|
WideGetCurrentDir: WideString |
Returns current working directory. |
WideSetCurrentDir (const Dir: WideString): Boolean |
Sets current working directory. |
WideGetTempPath: WideString |
Returns system temporary directory. Returns empty string if path cannot be determined. |
WideGetEnvironmentVar (const VarName: WideString): WideString |
Returns environment variable value by name (e.g., "USERNAME", "COMPUTERNAME"). |
Miscellaneous
| Function | Description |
|---|---|
Error (const Message: String) |
Terminates script with error message. Added in v7.2.0.7 Beta. |
Sleep (Milliseconds: Cardinal) |
Pauses script execution for specified milliseconds. |
DivMod (Dividend: Integer; Divisor: Word; var Result, Remainder: Word) |
Performs integer division and returns both quotient and remainder. |
Randomize |
Initializes random number generator. Should only be called once per session. |
RandomRange (const AFrom, ATo: Integer): Integer |
Returns random integer from AFrom (inclusive) to ATo (exclusive). |
RandomFloat: Extended |
Returns random floating point value from 0.0 (inclusive) to 1.0 (exclusive). Added in v6.2.0.8 Beta. |
RandomBoolean: Boolean |
Returns random boolean value (True or False).Added in v6.2.0.8 Beta. |
RandomString (Len: Integer; const Chars: String): String |
Generates random string of length Len using characters from Chars.Added in v6.7.0.4 Beta. |
MinInt (const A, B: Integer): Integer |
Returns smaller of two Integer values. Added in v6.2.0.8 Beta. |
MinInt64 (const A, B: Int64): Int64 |
Returns smaller of two Int64 values. Added in v6.2.0.8 Beta. |
MinFloat (const A, B: Extended): Extended |
Returns smaller of two Extended values. Added in v6.2.0.8 Beta. |
MaxInt (const A, B: Integer): Integer |
Returns larger of two Integer values. Added in v6.2.0.8 Beta. |
MaxInt64 (const A, B: Int64): Int64 |
Returns larger of two Int64 values. Added in v6.2.0.8 Beta. |
MaxFloat (const A, B: Extended): Extended |
Returns larger of two Extended values. Added in v6.2.0.8 Beta. |
GetClipboardText: WideString |
Returns text content from clipboard. |
SetClipboardText (const S: WideString) |
Sets text content to clipboard. |
Base64Encode (const S: String): String |
Encodes string to Base64 format. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet. |
Base64Decode (const S: String): String |
Decodes Base64 encoded string. |
URLEncode (const Str: WideString; UsePlusAsSpace: Boolean): String |
Encodes string for URL. Input string is encoded with UTF-8, then all characters except digits and Latin letters are encoded in %XX hex format. Optionally, white spaces can be encoded as plus signs ("+") by enabling the UsePlusAsSpace parameter, for compatibility with some decoders such as in PHP.Added in v5.74.4 Beta. |
URLDecode (const Str: String; UsePlusAsSpace: Boolean): WideString |
Decodes URL encoded string. All occurrences of %XX hex format are decoded, then entire string is decoded from UTF-8. Optionally, plus signs ("+") can be interpreted as white space by enabling the UsePlusAsSpace parameter, for compatibility with some encoders such as in PHP.Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta. |
GetTickCount: Cardinal |
Returns milliseconds since system start (resets after ~49.7 days). Limited precision. |
SizeOf (X): Integer |
Returns number of bytes used to represent a variable or type. |