Pascal Script: Functions
TODO: Review, update links.
This page provides a complete reference of all functions available in the Pascal Script rule 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 not 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 the first 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 the first 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 that appear in CharsToTrim from the beginning and end of S.Added in v6.0.0.9 Alpha. |
WideTrimCharsLeft (const S, CharsToTrim: WideString): WideString |
Removes characters that appear in CharsToTrim from the beginning of S.Added in v6.0.0.9 Alpha. |
WideTrimCharsRight (const S, CharsToTrim: WideString): WideString |
Removes characters that appear 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 is uppercase according to Unicode character properties. |
IsWideCharLower (WC: WideChar): Boolean |
Checks if character is lowercase according to Unicode character properties. |
IsWideCharDigit (WC: WideChar): Boolean |
Checks if character is a numeric digit (0-9 in any script). |
IsWideCharSpace (WC: WideChar): Boolean |
Checks if character is whitespace (spaces, tabs, line breaks, and other Unicode whitespace characters). |
IsWideCharPunct (WC: WideChar): Boolean |
Checks if character is a punctuation mark according to Unicode character properties. |
IsWideCharCntrl (WC: WideChar): Boolean |
Checks if character is a control character (non-printing characters like null, backspace, escape, etc.). |
IsWideCharBlank (WC: WideChar): Boolean |
Checks if character is a blank (space or tab). |
IsWideCharXDigit (WC: WideChar): Boolean |
Checks if character is a hexadecimal digit (0-9, A-F, a-f). |
IsWideCharAlpha (WC: WideChar): Boolean |
Checks if character is alphabetic according to Unicode character properties. This includes letters from all scripts (Latin, Arabic, Chinese, Cyrillic, etc.). |
IsWideCharAlphaNumeric (WC: WideChar): Boolean |
Checks if character is alphabetic or numeric according to Unicode character properties. |
IsWideWordBoundaryLeft (const Subject: WideString; CharPosition: Integer): Boolean |
Checks if a character at the specified position is on a word boundary to the left. A word boundary to the left exists if: (1) it's the first character and is a word character, or (2) it's between a word character and a non-word character. 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. A word boundary to the right exists if: (1) it's the last character and is a word character, or (2) it's between a word character and a non-word character. Added in v6.6.0.1 Beta. |
WideCharUpper (const WC: WideChar): WideChar |
Converts character to uppercase according to Unicode case mapping rules. Non-alphabetic characters are returned unchanged. |
WideCharLower (const WC: WideChar): WideChar |
Converts character to lowercase according to Unicode case mapping rules. 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: These functions use Windows character classification based on Unicode character properties. For technical details, see the GetStringTypeW function in the Windows API documentation.
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 the 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 the 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. For example, IntToStr(123) returns '123' 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. For example, StrToInt('123') returns 123 integer.Warning: Raises an error if the string cannot be converted to an integer. |
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 instead of raising an error. |
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. The converted value is stored in Value parameter. |
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. The Digits parameter specifies minimum number of digits (padded with zeros if needed). Examples:• IntToHex(1234, 1) returns '4D2'• IntToHex(1234, 8) returns '000004D2' |
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 (depending on month/year). 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. If successful, the generated date value is written to the Date parameter. |
TryEncodeTime (Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean |
Like EncodeTime but returns True/False instead of raising an error. If successful, the generated time value is written to the Time parameter. |
TryEncodeDateTime (Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean |
Like EncodeDateTime but returns True/False instead of raising an error. If successful, the generated date-time value is written to the ADateTime parameter.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 a custom date and time format. |
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 all folders exist or were successfully created. |
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 (a quirk of Windows API).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 list of path names). 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", "C:\Folder\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., "Document.txt" → "Document", "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. For example, going from "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. On Windows, filenames are case-insensitive for comparison purposes but case-preserving when creating new files. 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 number of characters from file starting at position Start (0-based, so 0 is the beginning of the file). |
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, so 1 is the first line). Note: This function is extremely inefficient and provided only for convenience. Avoid using it repeatedly. |
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. 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 and time format instead of application default.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). The function matches the entire expression. |
SubMatchesRegEx (const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray |
Returns array of sub-expression matches for the first full match only. This can be combined with MatchesRegEx to find all global matches, then parse each match through SubMatchesRegEx to extract individual sub-expression matches. |
Example matches for MatchesRegEx and SubMatchesRegEx:
| Input | Pattern | MatchesRegEx | SubMatchesRegEx |
|---|---|---|---|
| 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. For example, you can open a Word document or web page and the associated application will launch. Warning: This function evaluates the command and may produce unexpected results. For example, ShellOpenFile('notepad') could run 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. The WaitForProgram parameter specifies whether to wait for the program to finish before continuing. 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 ◦ More information: ShowWindow API function 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. This function should be used only for console applications.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) |
Same as ShowMessage but with Unicode text support. |
DialogYesNo (const Msg: String): Boolean |
Shows Yes/No dialog. Returns True if user clicks Yes. |
WideDialogYesNo (const Msg: WideString): Boolean |
Same as DialogYesNo but with Unicode text support. |
InputBox (const ACaption, APrompt, ADefault: String): String |
Shows input dialog with text box. If user clicks OK, returns the entered value, otherwise returns the default value. |
InputQuery (const ACaption, APrompt: String; var Value: String): Boolean |
Shows input dialog. Returns True if user clicks OK. The entered value is stored in the Value parameter. |
WideInputBox (const ACaption, APrompt, ADefault: WideString): WideString |
Same as InputBox but with Unicode text support. |
WideInputQuery (const ACaption, APrompt: WideString; var Value: WideString): Boolean |
Same as InputQuery but with Unicode text support. |
Application
| Function | Description |
|---|---|
GetApplicationPath: WideString |
Returns full path to ReNamer executable (e.g., "C:\Program Files\ReNamer\ReNamer.exe"). |
GetApplicationParams: TWideStringArray |
Returns array of command line parameters passed to the application at launch. |
GetCurrentFileIndex: Integer |
Returns index of current file being processed (ranges from 1 to GetTotalNumberOfFiles). |
GetTotalNumberOfFiles: Integer |
Returns total number of files in the list. |
GetCurrentMarkedFileIndex: Integer |
Returns index of current file among marked files only (ranges from 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 value if variable doesn't exist. |
GetGlobalVarDef (const Name: String; Default: Variant): Variant |
Gets a global variable. Returns 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 in a single operation. • Dividend — The value being divided• Divisor — The value to divide by• Result — Receives the quotient (result of division)• Remainder — Receives the remainder (the difference between Result * Divisor and Dividend) |
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). For example, RandomRange(1, 10) returns a value between 1 and 9, inclusive. |
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 to minimize the likelihood of corruption when transmitted through systems like email or web. |
Base64Decode (const S: String): String |
Decodes Base64 encoded string. |
URLEncode (const Str: WideString; UsePlusAsSpace: Boolean): String |
Encodes string for URL use. The input string is first encoded to UTF-8, then all characters except digits and Latin letters are encoded as %XX hex sequences. If UsePlusAsSpace is True, spaces are encoded as plus signs ("+") instead of "%20" (for compatibility with some decoders like PHP).Added in v5.74.4 Beta. |
URLDecode (const Str: String; UsePlusAsSpace: Boolean): WideString |
Decodes URL encoded string. All %XX hex sequences are decoded, then the entire string is decoded from UTF-8. If UsePlusAsSpace is True, plus signs ("+") are interpreted as spaces (for compatibility with some encoders like 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. Pass a variable to get its size, or pass a type identifier to get the size of that type. |