Forum Discussion

johnjohn-Peter's avatar
johnjohn-Peter
Iron Contributor
Jan 28, 2024

How i can get the most recent file inside "List files in folder" one drive

I have this flow, where i am getting all the root folders inside a user onedrive:-

 

 

 
 

 

 

then i am using "List files in folder" >> to get all the files inside each root folder. but i do not need all files i only need the latest file inside each of the root folders? any advice?

Thanks

  • SanthoshB1's avatar
    SanthoshB1
    Bronze Contributor

     1.Add a compose to sorting the Folder files and get the recent one.

    first(reverse(sort(outputs('List_files_in_folder')?['body/value'], 'LastModified')))

     

    2.Utilize the 'Filter array' action to narrow down the selection of recent files, specifically targeting those files added at the same timestamp.

    {

        "inputs": {

            "from": "@outputs('List_files_in_folder')?['body/value']",

            "where": "@equals(item()?['LastModified'], outputs('Sorting_Files')?['LastModified'])"

        }

    It will loop and process each folder wise. you can make a further action along with it.

     

     

    Let me know if this helps for you.

    johnjohn-Peter

Resources