Skip to main content
Solved

Pick up Latest File from Folder Location

  • November 1, 2019
  • 11 replies
  • 619 views

Forum|alt.badge.img

Hi,

Newbie type question. I am currently loading in files to a output on a weekly basis. Issue has been I have to edit the file in the workbench with the new filename.

The file I upload changes on a daily basis with its name. How can FME pick up the latest file that has been updated without having to change the file path on a daily basis?

I have tried to use this https://knowledge.safe.com/questions/65203/read-only-the-newest-file-from-a-directory.html method but unfortunately I am not getting it to work. I also do not need to generate any further data to my existing table, just was interested in the function where it can automatically pick up the latest file at folder level by date modified.

 

Thank You

Best answer by danullen

1. As your source, use a Directory and File Pathnames reader.

 

2. A Sorter that sorts descending on path_modified_date.

 

3. A Sampler that only lets the first feature pass.

 

4. A FeatureReader where Dataset is set to path_windows.
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

11 replies

Forum|alt.badge.img
  • 104 replies
  • Best Answer
  • November 1, 2019

1. As your source, use a Directory and File Pathnames reader.

 

2. A Sorter that sorts descending on path_modified_date.

 

3. A Sampler that only lets the first feature pass.

 

4. A FeatureReader where Dataset is set to path_windows.

nielsgerrits
VIP
Forum|alt.badge.img+60
  • 2938 replies
  • November 1, 2019

1. As your source, use a Directory and File Pathnames reader.

 

2. A Sorter that sorts descending on path_modified_date.

 

3. A Sampler that only lets the first feature pass.

 

4. A FeatureReader where Dataset is set to path_windows.

This is why I believe the FeatureReader and FeatureWriter are the biggest game changing transformers in a long time.


Forum|alt.badge.img
  • Author
  • 25 replies
  • November 1, 2019

1. As your source, use a Directory and File Pathnames reader.

 

2. A Sorter that sorts descending on path_modified_date.

 

3. A Sampler that only lets the first feature pass.

 

4. A FeatureReader where Dataset is set to path_windows.

path2none.fmwThanks Dan - I have put this together, is this correct in the way its working. In terms of then adding the rest of my workbench in terms of filtering out records, does this get attached towards the schema.

path2none.fmw


Forum|alt.badge.img
  • 104 replies
  • November 1, 2019

path2none.fmwThanks Dan - I have put this together, is this correct in the way its working. In terms of then adding the rest of my workbench in terms of filtering out records, does this get attached towards the schema.

path2none.fmw

Almost perfect I think. :)

You just need to change from ascending to descending in the Sorter, to get the newest file instead of the oldest.


Forum|alt.badge.img
  • Author
  • 25 replies
  • November 1, 2019

Almost perfect I think. :)

You just need to change from ascending to descending in the Sorter, to get the newest file instead of the oldest.

Thanks Dan, i got this working now. In regards to seeing data after the featurereader, is there any specific changes that need to be made? At the featurereader I only get information in regards to the file it is will pick up. Thanks again.


Forum|alt.badge.img
  • 104 replies
  • November 1, 2019

Thanks Dan, i got this working now. In regards to seeing data after the featurereader, is there any specific changes that need to be made? At the featurereader I only get information in regards to the file it is will pick up. Thanks again.

Have you set the Format in the FeatureReader so that FME knows what it's looking at? If the Format is set correctly, and the Dataset points to a valid file (through the path_windows attribute) FME should be able to read the file and extract the features. If it still doesn't work, please post a screen dump of the FeatureReader settings or the .fmw.


Forum|alt.badge.img
  • Author
  • 25 replies
  • November 4, 2019

Have you set the Format in the FeatureReader so that FME knows what it's looking at? If the Format is set correctly, and the Dataset points to a valid file (through the path_windows attribute) FME should be able to read the file and extract the features. If it still doesn't work, please post a screen dump of the FeatureReader settings or the .fmw.

Hi Dan, apologise for delay in response. I am getting the records to come through it seems as the file count of the file is 227. But I am getting a empty table with no attributes. It is a excel file. Capture.JPG path2none.fmw


Forum|alt.badge.img
  • 104 replies
  • November 4, 2019

Hi Dan, apologise for delay in response. I am getting the records to come through it seems as the file count of the file is 227. But I am getting a empty table with no attributes. It is a excel file. Capture.JPG path2none.fmw

At the bottom of the FeatureReader parameters dialog box you've got "<Generic> Port". You might need to go in there and expose your attributes to get them to show.


Forum|alt.badge.img
  • Author
  • 25 replies
  • November 4, 2019

At the bottom of the FeatureReader parameters dialog box you've got "<Generic> Port". You might need to go in there and expose your attributes to get them to show.

That seems to be the issue. I have manually setup the attributes, so this now has picked up the attributes. This process is good as long as the source file does not change.


katie.grey
Participant
Forum|alt.badge.img+1
  • Participant
  • 1 reply
  • August 14, 2025

Hi, I am currently trying to do this process but have noticed that I am unable to expose the same attributes as what are exposed on the example workspace provided. These are exposed on provided workspace 

 

And this is what I am able to see on mine 

 

I’ve tried different directories and drives, but I still get the same error. Is this something that I am doing incorrectly or could it be related to our IT settings? 


crystalatsafe
Safer
Forum|alt.badge.img+23
  • Safer
  • 153 replies
  • August 18, 2025

Hi ​@katie.grey 

You may find this post helpful: path_modified_date and Directory and File Pathnames Reader

In the Directory and File Pathnames Parameters set Retrieve file properties to yes.