SplitFileName

Splits a file name into user specified variables.

Member of namespace

FileIO

Syntax

bool SplitFileName (string inputFilename, string rootPathVariable, string pathVariable, string fileVariable, string extVariable)

Parameters

inputFilename
Type: string
rootPathVariable
Type: string
pathVariable
Type: string
fileVariable
Type: string
extVariable
Type: string

Parameters

  • inputFilename : The input file name to break into its three logical parts.
  • rootPathVariable : The name of the variable to store the root path.
  • pathVariable : The name of the variable to store the file path.
  • fileVariable : The name of the variable to store the file name without the extension.
  • extVariable : The name of the variable to store the file extension.

Smart parameters are supported for each of the input parameters. For each of the parameters that accept a variable, the level must be specified with a Smart Parameter.

It is not necessary to specify a variable name for each part of the path that is split. Only destination variables for the desired values need to be specified. If you do not want to store a particular file name part, leave that parameter blank.

Returns

False if the structure of the file name or path is invalid. Otherwise, True. The file does not need to exist for this action to succeed.

Level

All levels.

Details

This action splits the input file name into its root path, path, file name and the extension, and place each of the parts into their own variables. The file does not need to exist.

If the file contains a file extension, the saved file extension will contain a preceding period.

Example
Code Comment
SplitFileName("C:\Dir1\Dir2\MyFile.abc","@B.FROOT","@B.FPATH", "@B.FNAME","@B.FEXT") Splits the file name and saves the information into four variables at the batch level:
  • FROOT = "C:\"
  • FPATH = "C:\Dir1\Dir2"
  • FNAME = "MyFile"
  • FEXT = ".abc"
SplitFileName("@VAR(IMAGEFILE)","","","","@B.EXT") Obtains the value that is stored in the variable IMAGEFILE and saves the file extension into a variable EXT.
SplitFileName("@P.ScanSrcPath","","","@P\Fieldname.Text","") Obtains the value that is stored in the page variable ScanSrcPath and saves the file name into the subfield Text.