1

I am trying to get the Last Modified date on the files (CSV linked service) in my repository using Get Metadata activity.

Field List

However, I am getting the same date/time for all of the files... the LastModified date on the folder instead of the individual files inside.

same LastModifiedDate output example

My design pattern is to Get the list of files and then iterate in a For Each over each item.

Synapse Pipeline design pattern

I am able to get the Filenames with

@activity('Get Metadata').output.childItems

I just don't see a LastModified date in the attributes of the Jason.

This code needs to go a level deeper:

@activity('Get Metadata').output.lastModified

What is the syntax I am missing to access each of the file properties?

Aswin
  • 4,090
  • 2
  • 4
  • 16
CFCJB
  • 11
  • 4

1 Answers1

0

To Get Metadata Last Modified Date on file instead of on folder Follow below steps:

  • First you need to get the list of files. using Get metadata activity and field list as Child items. enter image description here

  • Then pass this child items to the Foreach activity to loop on that. enter image description here

  • Under this foreach activity take another get metadata activity to get Last modified date for each file. enter image description here For this activity use parameterized data set with filename. -- Create parameter in Dataset enter image description here -- Use this parameter in the dataset. enter image description here

  • Then append your required values in Append Variable with expression:

@json(Concat('{"name": "',item().name,'",','"lastModified": "',activity('Get Metadata2').output.lastModified,'"}'))

enter image description here

This will create an array with Json of filename and last modified date of each file the use it further.

Output:

enter image description here

Pratik Lad
  • 4,343
  • 2
  • 3
  • 11
  • error: No value provided for Parameter 'filename' I added the parameter 'filename' to the Linked Service. and then for File Path have \\MyFilePath / / @dataset().filename Preview Data does not return any results. "Please provide actual value of the parameters to preview data" It looks like the datasource is expecting a value for the filename. It should just grab what is in the directory. – CFCJB Aug 28 '23 at 17:19