David_Teh Respected Contributor.
Respected Contributor.
466 views

How to store latest file as flow variable

Hi all,

Am trying to configure a flow variable to be the latest possible file in a certain location. I more or less know how to assign a file's location as a flow variable but am not sure on how to get oo to capture the latest possible file as the variable. My file name is always populated as xxx_20170502172130 (YearYearYearYearMonthMonthDayDayHourHourMinMinSecSec).

Thanks in advance for any help!

David

Labels (1)
Tags (3)
0 Likes
3 Replies
AndreiTruta Outstanding Contributor.
Outstanding Contributor.

Re: How to store latest file as flow variable

What do you want to achieve?

As a variable you could use get time to get the current time and compose a variable like xxx_${currenttime_formatted}, of course after you format the current time at the desired format.

As for getting a file from a directory you could parse the list of directory files and compare the modification time (using FS Modified).

Andrei Vasile Truta
0 Likes
David_Teh Respected Contributor.
Respected Contributor.

Re: How to store latest file as flow variable

Hi Andrel

I have a folder of .txt files and im trying to get the latest possible file when I run a flow. To do that, I was planning to store the location of the latest file as a flow variable to access throughout my flow as and when needed.

So what you are suggesting is that I use FS Modified to parse the directory of all the files and compare the modification time to get the one closeset to what I have? How would that work exactly? Would I have to iterate through the entire directory by using the list iterator for example?


Thanks!
David

0 Likes
AndreiTruta Outstanding Contributor.
Outstanding Contributor.

Re: How to store latest file as flow variable

Hi David,

Something like that indeed. You could also have a list appender in case (in some cases) you will end up with more "recent" files.Screenshot_42.png

 

 

 

Andrei Vasile Truta
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.