Skip to main content
Solved

Select Files with path_modified_date last year


vxn43
Supporter
Forum|alt.badge.img+18

I have files in a folder. I want to select the files with a path_modified_date from the year prior. Example, if the path_modified_date contains "prior year" then zip these files. I know how to do the zip files part.

 

It is the If the path_modified_date contains "prior year" part that I am having trouble with. The files in question accumulate every year and I would like to set up an automation in FME Flow that runs every March and zips the files from the previous year. I know how to set up an automation.

 

Here is what I have done so far in FME Form. The Tester passed if @Value(path_modified_date) Contains 2022; If I use this workbench as is, every year I want to run the workspace I would need to go in and manually change the Right Value in the Tester to the prior year. I want to know if there is a way where I can automate this portion?

FME_Workbench_Screenshot_5I added a Year field to Attribute Manager takes the left 4 digits (the year) from the path_modified_date field. Then I changed the Right Value of the Tester Parameters to arithmetic, @Value(Year)-1), but it does not seem to work, maybe I am on the right track?

 FME_Workbench_Screenshot_6

Best answer by boydfme

If you want to keep using the Tester like you have, you could automate it this way:

 

Right Value would need to be set to arithmetic calculator and then just copy paste in:

@DateTimeFormat(@DateTimeNow(),%Y)-1

###@DateTimeNow() is the fme command to get the current Date and time based on the machine fme is being ran.

### %Y gets just the year date from DateTimeNow()

###@DateTimeFormat() makes it a datetime format

### then just subtract 1 year to get previous

image 

Example:

image

View original
Did this help you find an answer to your question?

3 replies

boydfme
Contributor
Forum|alt.badge.img+6
  • Contributor
  • Best Answer
  • August 21, 2023

If you want to keep using the Tester like you have, you could automate it this way:

 

Right Value would need to be set to arithmetic calculator and then just copy paste in:

@DateTimeFormat(@DateTimeNow(),%Y)-1

###@DateTimeNow() is the fme command to get the current Date and time based on the machine fme is being ran.

### %Y gets just the year date from DateTimeNow()

###@DateTimeFormat() makes it a datetime format

### then just subtract 1 year to get previous

image 

Example:

image


vxn43
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • August 22, 2023

Would you happen to know a link that would show a list and explanation of FME Commands, like the @@DateTimeNow()?

 

It would be a great resource for me to refer to.


boydfme
Contributor
Forum|alt.badge.img+6
  • Contributor
  • August 22, 2023

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings