Skip to main content

Pascal Script: Functions

TODOTODO: Review, fix all 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

FunctionDescription
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): StringCopies Count characters from string S, starting at position Index, and returns them as a new string.
Pos (Substr: String; S: String): IntegerReturns 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

FunctionDescription
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): IntegerReturns the length of array S (number of elements).
Length (const S: String): IntegerReturns the length of string S (number of characters).
Length (const S: WideString): IntegerReturns the length of WideString S (number of characters).

Wide String Handling

FunctionDescription
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): IntegerReturns the length of WideString S.
WideCopy (const S: WideString; Index, Count: Integer): WideStringReturns Count characters from S, starting at position Index.
WideCopyRight (const S: WideString; Index, Count: Integer): WideStringReturns 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): IntegerFinds an occurrence of SubStr in S. Returns the position of first occurrence, or 0 if not found.
WidePosEx (const SubStr, S: WideString; Offset: Cardinal): IntegerFinds 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): WideStringReturns the uppercase version of WideString S.
WideLowerCase (const S: WideString): WideStringReturns the lowercase version of WideString S.
WideCompareStr (const S1, S2: WideString): IntegerCompares 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): IntegerCompares 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): BooleanCompares two WideStrings case-insensitively. Returns True if identical, otherwise False.
WideTextPos (const SubStr, S: WideString): IntegerLike WidePos but case-insensitive.
WideTextPosEx (const SubStr, S: WideString; Offset: Cardinal): IntegerLike WidePosEx but case-insensitive.
Added in v6.6.0.1 Beta.
WideTrim (const S: WideString): WideStringRemoves leading and trailing spaces and control characters from string S.
WideTrimChars (const S, CharsToTrim: WideString): WideStringRemoves characters in CharsToTrim from the beginning and end of S.
Added in v6.0.0.9 Alpha.
WideTrimCharsLeft (const S, CharsToTrim: WideString): WideStringRemoves characters in CharsToTrim from the beginning of S.
Added in v6.0.0.9 Alpha.
WideTrimCharsRight (const S, CharsToTrim: WideString): WideStringRemoves characters in CharsToTrim from the end of S.
Added in v6.0.0.9 Alpha.
WideReverseString (const S: WideString): WideStringReturns a reversed version of string S.
Added in v6.7.0.4 Beta.
WideRepeatString (const S: WideString; Count: Integer): WideStringRepeats string S the specified number of times.
Added in v6.9.0.3 Beta.
WideReplaceStr (const S, OldPattern, NewPattern: WideString): WideStringReplaces all case-sensitive occurrences of OldPattern with NewPattern in string S.
WideReplaceText (const S, OldPattern, NewPattern: WideString): WideStringReplaces all case-insensitive occurrences of OldPattern with NewPattern in string S.
WideSplitString (const Input, Delimiter: WideString): TWideStringArraySplits 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): WideStringJoins all items from Strings into a single WideString, with Delimiter inserted between items.
WideCaseSentence (const S: WideString): WideStringReturns 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): WideStringReturns title case version of S. First letter of every word is capitalized, all others are lowercase.
WideCaseInvert (const S: WideString): WideStringInverts the case of all characters in S.

Wide String Array Handling

FunctionDescription
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): TWideStringArrayCopies 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): TWideStringArrayConcatenates two WideString arrays.
Added in v7.5.0.3 Beta.

Wide Character Handling

FunctionDescription
IsWideCharUpper (WC: WideChar): BooleanChecks if character WC is uppercase.
IsWideCharLower (WC: WideChar): BooleanChecks if character WC is lowercase.
IsWideCharDigit (WC: WideChar): BooleanChecks if character WC is a digit (0-9).
IsWideCharSpace (WC: WideChar): BooleanChecks if character WC is whitespace (space, tab, newline, etc.).
IsWideCharPunct (WC: WideChar): BooleanChecks if character WC is a punctuation mark.
IsWideCharCntrl (WC: WideChar): BooleanChecks if character WC is a control character.
IsWideCharBlank (WC: WideChar): BooleanChecks if character WC is blank (space or tab).
IsWideCharXDigit (WC: WideChar): BooleanChecks if character WC is a hexadecimal digit (0-9, A-F).
IsWideCharAlpha (WC: WideChar): BooleanChecks if character WC is alphabetic (a-z, A-Z).
IsWideCharAlphaNumeric (WC: WideChar): BooleanChecks if character WC is alphanumeric (a-z, A-Z, 0-9).
IsWideWordBoundaryLeft (const Subject: WideString; CharPosition: Integer): BooleanChecks 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): BooleanChecks 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): WideCharReturns uppercase version of the character. Non-alphabetic characters are returned unchanged.
WideCharLower (const WC: WideChar): WideCharReturns lowercase version of the character. Non-alphabetic characters are returned unchanged.
WideChr (Code: Word): WideCharCreates 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

FunctionDescription
WideToAnsi (const WS: WideString): StringConverts WideString to AnsiString. In v7.0 and later, this conversion happens automatically on assignment.
AnsiToWide (const S: String): WideStringConverts AnsiString to WideString. In v7.0 and later, this conversion happens automatically on assignment.
UTF8Encode (const WS: WideString): StringConverts WideString to UTF-8 encoded string.
UTF8Decode (const S: String): WideStringConverts UTF-8 encoded string to WideString.
WinCPToUTF8 (const S: String): StringConverts a string encoded with active system code page to UTF-8.
Added in v7.4.0.3 Beta.
UTF8ToWinCP (const S: String): StringConverts 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.

FunctionDescription
OemToAnsi (const S: String): StringConverts OEM string to ANSI string.
Added in v6.6.0.2 Beta.
OemToWide (const S: String): WideStringConverts OEM string to WideString.
Added in v6.6.0.2 Beta.
AnsiToOem (const S: String): StringConverts ANSI string to OEM string.
Added in v6.6.0.2 Beta.
WideToOem (const S: WideString): StringConverts WideString to OEM string.
Added in v6.6.0.2 Beta.

Basic Conversion

FunctionDescription
BoolToStr (B: Boolean): StringConverts boolean value to string. Returns "True" or "False".
IntToStr (Value: Integer): StringConverts 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): StringConverts an Int64 value to string.
StrToInt (const S: String): IntegerConverts a string to integer. Raises an error if conversion fails.
StrToInt64 (const S: String): Int64Converts a string to Int64. Raises an error if conversion fails.
StrToIntDef (const S: String; const Default: Integer): IntegerConverts a string to integer. Returns Default value if conversion fails.
StrToInt64Def (const S: String; Default: Int64): Int64Converts a string to Int64. Returns Default value if conversion fails.
TryStrToInt (const S: String; out Value: Integer): BooleanConverts a string to integer. Returns False if conversion fails instead of raising an error.
FloatToStr (Value: Extended): StringConverts floating point value to string using default system format.
StrToFloat (const S: String): ExtendedConverts string to floating point value. Raises an error if conversion fails.
StrToFloatDef (const S: String; const Default: Extended): ExtendedConverts string to floating point value. Returns Default value if conversion fails.
FormatFloat (const Format: String; Value: Extended): StringConverts floating point value to string using custom format. See floating point format specifiers below.
DateToStr (D: TDateTime): StringConverts date to string using system short date format (e.g., dd/mm/yyyy).
StrToDate (const S: String): TDateTimeConverts date string to TDateTime using system short date format (e.g., dd/mm/yyyy).
IntToHex (Value: Integer; Digits: Integer): StringConverts integer to hexadecimal representation. Digits specifies minimum number of digits (padded with zeros).
HexToInt (const HexNum: String): IntegerConverts hexadecimal string to integer. Raises an error if conversion fails.
HexToIntDef (const HexNum: String; Default: Integer): IntegerConverts hexadecimal string to integer. Returns Default value if conversion fails.
IntToRoman (Value: Integer): StringConverts decimal number to Roman numerals.
Added in v7.3.0.4 Beta.
RomanToInt (const S: String): IntegerConverts Roman numerals to decimal number.
Added in v7.3.0.4 Beta.
RomanToIntDef (const S: String; Default: Integer): IntegerConverts Roman numerals to decimal number. Returns Default if conversion fails.
Added in v7.3.0.4 Beta.
TryRomanToInt (const S: String; out Value: Integer): BooleanConverts 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): ByteReturns ordinal value (byte representation) of a character.
Chr (X: Byte): CharReturns a character from its ordinal value (byte representation).

Floating point format specifiers

SpecifierDescription
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

FunctionDescription
Date: TDateTimeReturns the current system date.
Time: TDateTimeReturns the current system time.
Now: TDateTimeReturns the current system date and time.
EncodeDate (Year, Month, Day: Word): TDateTimeCreates 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): TDateTimeCreates 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): TDateTimeCreates 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): BooleanLike EncodeDate but returns True/False instead of raising an error.
TryEncodeTime (Hour, Min, Sec, MSec: Word; var Time: TDateTime): BooleanLike EncodeTime but returns True/False instead of raising an error.
TryEncodeDateTime (Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): BooleanLike 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): TDateTimeCombines separate date and time values into a single TDateTime value.
Added in v6.2.0.5 Beta.
DateTimeToUnix (D: TDateTime): Int64Converts TDateTime value to Unix timestamp.
UnixToDateTime (U: Int64): TDateTimeConverts Unix timestamp to TDateTime value.
FormatDateTime (const Format: String; DateTime: TDateTime): StringConverts date and time to string using custom Date and Time formatting.
ScanDateTime (const Pattern, Subject: String): TDateTimeParses 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): BooleanLike ScanDateTime but returns True/False instead of raising an error.
Added in v7.1.0.3 Beta.
IncYear (const AValue: TDateTime; const ANumberOfYears: Integer): TDateTimeAdds or subtracts years from a TDateTime value.
IncMonth (const AValue: TDateTime; ANumberOfMonths: Integer): TDateTimeAdds or subtracts months from a TDateTime value.
IncWeek (const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTimeAdds or subtracts weeks from a TDateTime value.
IncDay (const AValue: TDateTime; const ANumberOfDays: Integer): TDateTimeAdds or subtracts days from a TDateTime value.
IncHour (const AValue: TDateTime; const ANumberOfHours: Int64): TDateTimeAdds or subtracts hours from a TDateTime value.
IncMinute (const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTimeAdds or subtracts minutes from a TDateTime value.
IncSecond (const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTimeAdds or subtracts seconds from a TDateTime value.
IncMilliSecond (const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTimeAdds or subtracts milliseconds from a TDateTime value.
SecondSpan (const ANow, AThen: TDateTime): DoubleCalculates approximate number of seconds between two date-time values.
Added in v6.2.0.5 Beta.
DayOfWeek (const DateTime: TDateTime): WordReturns 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): WordReturns the day number of the month.
Added in v6.1.
DayOfYear (const DateTime: TDateTime): WordReturns the day number of the year.
Added in v6.1.
WeekOfMonth (const DateTime: TDateTime): WordReturns the week number of the month.
Added in v6.1.
WeekOfYear (const DateTime: TDateTime): WordReturns the week number of the year.
Added in v6.1.

File Management

FunctionDescription
WideFileSize (const FileName: WideString): Int64Returns file size in bytes. Returns -1 if file does not exist.
WideFileExists (const FileName: WideString): BooleanChecks if specified file exists.
WideDirectoryExists (const Directory: WideString): BooleanChecks if specified directory exists.
WideForceDirectories (const Dir: WideString): BooleanEnsures all directories in the path exist, creating them recursively if needed. Returns True if successful.
WideCreateDir (const Dir: WideString): BooleanCreates specified directory (non-recursive). Returns True on success.
WideRemoveDir (const Dir: WideString): BooleanRemoves a directory if it is empty. Returns True on success.
Added in v6.4.0.1 Beta.
WideDeleteFile (const FileName: WideString): BooleanDeletes file from disk. Returns True on success.
WideDeleteToRecycleBin (const FileName: WideString): BooleanMoves 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): BooleanRenames file from OldName to NewName. Returns True on success.
WideCopyFile (const FromFile, ToFile: WideString; FailIfExists: Boolean): BooleanCopies 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): WideStringSearches 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

FunctionDescription
WideExtractFilePath (const FileName: WideString): WideStringReturns drive and directory portion with trailing path delimiter (e.g., "C:\Folder").
WideExtractFileDir (const FileName: WideString): WideStringReturns drive and directory portion without trailing path delimiter (e.g., "C:\Folder").
WideExtractFileDrive (const FileName: WideString): WideStringReturns the drive letter (e.g., "C:").
WideExtractFileName (const FileName: WideString): WideStringReturns filename with extension (e.g., "Document.txt").
WideExtractBaseName (const FileName: WideString): WideStringReturns filename without extension or path (e.g., "Document.txt" → "Document").
WideExtractFileExt (const FileName: WideString): WideStringReturns file extension with dot (e.g., ".txt").
WideChangeFileExt (const FileName, Extension: WideString): WideStringReplaces file extension (e.g., "File.txt" → "File.pdf").
WideStripExtension (const FileName: WideString): WideStringRemoves extension while preserving path (e.g., "C:\Folder\Document.txt" → "C:\Folder\Document").
WideExpandFileName (const FileName: WideString): WideStringConverts relative filename to fully qualified path. Does not verify file existence.
WideExtractRelativePath (const BaseName, DestName: WideString): WideStringCreates 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): WideStringConverts path to DOS 8.3 format.
WideIncludeTrailingPathDelimiter (const S: WideString): WideStringEnsures path ends with path delimiter ("").
WideExcludeTrailingPathDelimiter (const S: WideString): WideStringEnsures path does not end with path delimiter ("").
WideSameFileName (const FileName1, FileName2: WideString): BooleanCompares filenames for equality (case-insensitive on Windows).
Added in v6.7.0.4 Beta.
WideMatchesMask (const FileName, Mask: WideString): BooleanChecks if filename matches wildcard mask (e.g., "*.txt").
Added in v6.7.0.4 Beta.
WideMatchesMaskList (const FileName, MaskList: WideString): BooleanChecks if filename matches any wildcard mask in semicolon-separated list (e.g., ".txt;.doc").
Added in v6.7.0.4 Beta.

File Read/Write

FunctionDescription
FileReadFragment (const FileName: WideString; Start, Length: Integer): StringReads Length characters from file starting at position Start (0-based).
FileReadLines (const FileName: WideString): TAnsiStringArrayReads all lines from a file and returns as array.
Added in v5.74.4 Beta.
FileReadLine (const FileName: WideString; LineNum: Integer): StringReads 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): IntegerCounts 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): StringReturns 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): WideStringReads text from file with automatic encoding detection.
Added in v6.6.0.6 Beta.
FileReadTextLines (const FileName: WideString): TWideStringArrayReads 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

FunctionDescription
FileTimeModified (const FileName: WideString): TDateTimeReturns last modified time of file.
FileTimeCreated (const FileName: WideString): TDateTimeReturns creation time of file.
SetFileTimeCreated (const FileName: WideString; const DateTime: TDateTime): BooleanSets creation time of file.
SetFileTimeModified (const FileName: WideString; const DateTime: TDateTime): BooleanSets last modified time of file.

Meta Tags Extraction

FunctionDescription
CalculateMetaTag (const FilePath: WideString; const MetaTagName: String): WideStringExtracts 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): WideStringSame 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.

Regular Expressions

FunctionDescription
IsMatchingRegEx (const Input, Pattern: WideString; const CaseSensitive: Boolean): BooleanChecks if input matches a regular expression pattern.
Added in v5.74.4 Beta.
ReplaceRegEx (const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideStringFinds 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): IntegerFinds 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 strings
Added in v7.3.0.4 Beta.
MatchesRegEx (const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArrayReturns array of full regex matches (not sub-patterns).
SubMatchesRegEx (const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArrayReturns 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:

InputPatternMatchesRegExSubMatchesRegEx
A1_B2_C3[A-Z]\dA1, B2, C3(empty)
A1_B2_C3([A-Z])(\d)A1, B2, C3A, 1

Process Execution

FunctionDescription
ShellOpenFile (const FileName: WideString): BooleanOpens 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): CardinalExecutes a command. WaitForProgram controls whether to wait for completion. Returns exit code.
ExecuteProgramShow (const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): CardinalExecutes 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): CardinalExecutes 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

FunctionDescription
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): BooleanShows Yes/No dialog. Returns True if user clicks Yes.
WideDialogYesNo (const Msg: WideString): BooleanShows Yes/No dialog with Unicode text support.
InputBox (const ACaption, APrompt, ADefault: String): StringShows input dialog with text box. Returns entered value or default if user cancels.
InputQuery (const ACaption, APrompt: String; var Value: String): BooleanShows input dialog. Returns True if user clicks OK. Entered value is stored in Value parameter.
WideInputBox (const ACaption, APrompt, ADefault: WideString): WideStringShows input dialog with Unicode text support.
WideInputQuery (const ACaption, APrompt: WideString; var Value: WideString): BooleanShows input dialog with Unicode text support and Boolean return value.

Application

FunctionDescription
GetApplicationPath: WideStringReturns full path to ReNamer executable.
GetApplicationParams: TWideStringArrayReturns array of command line parameters passed to application.
GetCurrentFileIndex: IntegerReturns index of current file being processed (1 to GetTotalNumberOfFiles).
GetTotalNumberOfFiles: IntegerReturns total number of files in the list.
GetCurrentMarkedFileIndex: IntegerReturns index of current file among marked files only (1 to GetTotalNumberOfMarkedFiles).
GetTotalNumberOfMarkedFiles: IntegerReturns total number of marked files.
GetAllFiles: TWideStringArrayReturns file paths of all files in the list.
Added in v5.74.2 Beta.
GetMarkedFiles: TWideStringArrayReturns 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.

FunctionDescription
SetGlobalVar (const Name: String; Value: Variant)Sets a global variable.
GetGlobalVar (const Name: String): VariantGets a global variable. Returns Unassigned if variable doesn't exist.
GetGlobalVarDef (const Name: String; Default: Variant): VariantGets a global variable with default fallback value.
HasGlobalVar (const Name: String): BooleanChecks if a global variable exists.
GetGlobalVarCount: IntegerReturns total number of global variables.
GetGlobalVarNames: TAnsiStringArrayReturns names of all global variables.
ClearGlobalVar (const Name: String)Clears a specific global variable.
ClearGlobalVarsClears all global variables.

System

FunctionDescription
WideGetCurrentDir: WideStringReturns current working directory.
WideSetCurrentDir (const Dir: WideString): BooleanSets current working directory.
WideGetTempPath: WideStringReturns system temporary directory. Returns empty string if path cannot be determined.
WideGetEnvironmentVar (const VarName: WideString): WideStringReturns environment variable value by name (e.g., "USERNAME", "COMPUTERNAME").

Example:

var
  UserName, ComputerName: WideString;
begin
  UserName := WideGetEnvironmentVar('USERNAME');
  ComputerName := WideGetEnvironmentVar('COMPUTERNAME');
end.

Miscellaneous

FunctionDescription
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.
RandomizeInitializes random number generator. Should only be called once per session.
RandomRange (const AFrom, ATo: Integer): IntegerReturns random integer from AFrom (inclusive) to ATo (exclusive).
RandomFloat: ExtendedReturns random floating point value from 0.0 (inclusive) to 1.0 (exclusive).
Added in v6.2.0.8 Beta.
RandomBoolean: BooleanReturns random boolean value (True or False).
Added in v6.2.0.8 Beta.
RandomString (Len: Integer; const Chars: String): StringGenerates random string of length Len using characters from Chars.
Added in v6.7.0.4 Beta.
MinInt (const A, B: Integer): IntegerReturns smaller of two Integer values.
Added in v6.2.0.8 Beta.
MinInt64 (const A, B: Int64): Int64Returns smaller of two Int64 values.
Added in v6.2.0.8 Beta.
MinFloat (const A, B: Extended): ExtendedReturns smaller of two Extended values.
Added in v6.2.0.8 Beta.
MaxInt (const A, B: Integer): IntegerReturns larger of two Integer values.
Added in v6.2.0.8 Beta.
MaxInt64 (const A, B: Int64): Int64Returns larger of two Int64 values.
Added in v6.2.0.8 Beta.
MaxFloat (const A, B: Extended): ExtendedReturns larger of two Extended values.
Added in v6.2.0.8 Beta.
GetClipboardText: WideStringReturns text content from clipboard.
SetClipboardText (const S: WideString)Sets text content to clipboard.
Base64Encode (const S: String): StringEncodes string to Base64 format.
Base64Decode (const S: String): StringDecodes Base64 encoded string.
URLDecode (const Str: String; UsePlusAsSpace: Boolean): WideStringDecodes URL encoded string. UsePlusAsSpace treats "+" as space for PHP compatibility.
Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.
URLEncode (const Str: WideString; UsePlusAsSpace: Boolean): StringEncodes string for URL. UsePlusAsSpace encodes spaces as "+" for PHP compatibility.
Added in v5.74.4 Beta.
GetTickCount: CardinalReturns milliseconds since system start (resets after ~49.7 days). Limited precision.
SizeOf (X): IntegerReturns number of bytes used to represent a variable or type.