Liquid Studio 2021
Data Mapping / Data Mapper Functions / By Category / File / GetDirectoryName
In This Topic
    GetDirectoryName
    In This Topic

    Function Name
    GetDirectoryName
    Category
    File
    Icon
    Description
    Return the index of the current item within its containing sequence
    Inputs
    Path The path of a file or directory.
    Outputs
    Directory Directory information for path.
    Properties
    None -

    Sample output

    Sample Path Output extension
    c:\temp\test.txt c:\temp
    c:\test.txt c:\
    .\temp\test.txt \temp
    test.txt
    c:\temp\test c:\temp
    c:\temp\ c:\temp
    "!InvalidPath' [ERROR]

     

    Example

    A range of functions are provided for working with Uri's and Path's. The following example demonstrates how these can be used.

     

    In the following example we have a directory c:\UriExamples\ that contains the files Bookstore.xsd, Input001.xml, Input002.xml & ResolvedUri.Output.xml.

    In our transform we have configured "ListFiles" to operate on the directory "c:\UriExamples\" and use the pattern "Input*.xml"

    As you can see the ListFiles component gets the full paths of all the files that match the pattern. These filenames are then fed into the various Uri functions and output into an XML writer.

    The result of the transform is as follows

    Transform Output
    Copy Code
    <FileProperties>
      <File>
        <FullFilename>C:\UriExamples\Input001.xml</FullFilename>
        <Filename>Input001.xml</Filename>
        <Extension>.xml</Extension>
        <Path>C:\UriExamples</Path>
        <AltFullFilename>C:\UriExamples\Backup\Input001.xml</AltFullFilename>
        <BackupFilename>C:\UriExamples\Input001.xml.bak</BackupFilename>
      </File>
      <File>
        <FullFilename>C:\UriExamples\Input002.xml</FullFilename>
        <Filename>Input002.xml</Filename>
        <Extension>.xml</Extension>
        <Path>C:\UriExamples</Path>
        <AltFullFilename>C:\UriExamples\Backup\Input002.xml</AltFullFilename>
        <BackupFilename>C:\UriExamples\Input002.xml.bak</BackupFilename>
      </File>
    </FileProperties>
    

    Let's examine the output in more detail

    Compatibility

    Native Execution Engine, XSLT 2.0, C#

    This is a scalar function so the standard rules apply if multiple values are presented to one or more inputs.

    See Also