User Guide > Scripting > Using Scripts to Perform Specific Tasks > Retrieving Source and Target Metadata
Was this helpful?
Retrieving Source and Target Metadata
These functions demonstrate capturing information about the source and target for the transformation.
Filename Example
The Filename function returns the file name, including the drive and directory path, of the source in this transformation:
This expression returns:
If you only want to return the file name (without drive and directory path), use this inside the Parse Function as follows:
Parse(4, Sources("SOURCE").Filename, "\")
This expression returns:
Note:  If the source is a database, this function returns null.
Database Example
This example returns the database name of the target in this transformation:
This expression returns:
Note:  If the target is a file-based connector, this function returns null.
Properties Example
The Properties function returns source or target properties values.
For instance, this example returns properties that you set in transformations.
Add the following code to a BeforeTransformation event:
FileWrite("outputfile", "Header = " & Sources("SOURCE").Properties("Header"))
After running the transformation, the file contains:
Header = True
Last modified date: 08/10/2022