Create File with Incrementing Suffix VI

Owning Palette: Advanced File VIs and Functions

Requires: Base Development System

Creates a file and appends an incrementing number suffix to the filename if the file already exists at a specified path. If the file does not exist, this VI creates the file without appending an incrementing number suffix to the filename.

Details  

 Add to the block diagram  Find on the palette
format string specifies how to convert the file path into a string. format string must contain exactly one decimal format code (%d). The default is " (%d)".
file path specifies the path to the file you want to create. You must specify an absolute path. If you specify an empty or relative path, this VI returns an error.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
disable buffering specifies if the file opens without buffering. The default is FALSE. If you want to read or write a data file to a Redundant Array of Independent Disks (RAID), consider opening the file without buffering to speed up data transfers. To disable buffering, wire a TRUE value to the disable buffering input.
Note  If you have a small amount of data to transfer, you might not notice a difference if you disable buffering.
(macOS and Linux) LabVIEW ignores this input.
refnum out returns the reference number of the file this VI creates.
actual path returns the path to the file this VI creates.
error out contains error information. This output provides standard error out functionality.

Create File with Incrementing Suffix Details

The following table displays examples of how this VI uses format string to convert file path and to return actual path.

Format String File Path Actual Path Description
" (%d)" C:\test.txt C:\test (1).txt The %d in format string specifies that the VI appends an incrementing number starting with 1 to the filename before the period (.).
"%4d" C:\test.txt C:\test   1.txt The 4 in format string specifies that the suffix after the filename and before the period (.) has a width of 4.