FIL. - File-Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Filesystem-Commands > FIL. - File-Commands >

FIL. - File-Commands

FIL.Generate Unique Filename

Previous Top Next


MiniRobotLanguage (MRL)

 

FIL.Generate Unique Filename

Generates a unique filename, ensuring no existing file is overwritten.

 

 

Intention

 

The FIL.Generate Unique Filename command is designed to create a unique filename based on an original filename (P1).

This is particularly useful in automated systems where files are dynamically generated and you want to avoid overwriting existing files.

If the file name in P1 is available then the File name is not changed, otherwise a "_(number)" is added before the extension.

If the file name is not available or contains a "?" then this is replaced by a unique number.

This command does not generate a file, will just deliver a valid name based on P1.

This command follows the scheme that is implemented in the SDL. Commands.

 

 

Original File Path Parsing: The command parses the original file name to extract the base name and the extension.

File Extension Validation: If the file extension is missing, .tmp is added as a default extension.

Placeholder Handling: If the base name contains a '?' character, it's replaced with a numeric counter formatted as a five-digit number (e.g., 00001, 00002, ...).

Uniqueness Check: The command iterates up to 100,000 times to find a unique file name.

 

 

Syntax

 

 

FIL.Generate Unique Filename|P1[|P2]

FIL.Guf|P1[|P2]

 

 

Parameter Explanation

 

P1 - Original Filename: Specifies the base filename you want to make unique. It may or may not have an extension.

P2 - Output Variable (Optional): If provided, the unique filename will be returned in this variable. If omitted, the result will be placed on the Top Of Stack (TOS).

 

 

 

 

Example

 

'***********************************

' FIL.-Sample for generating a unique filename

'***********************************

FIL.Generate Unique Filename|$$ORG|$$UNI

' $$UNI will now contain a unique filename based on $$ORG

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: