User Guide > 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:
Sources("SOURCE").Filename
This expression returns:
C:\TestData\MyData\tutor1.asc
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:
tutor1.asc
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:
Targets("TARGET_1").Database
This expression returns:
imqdb
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: 01/25/2022