web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Move only top file fro...
Power Automate
Answered

Move only top file from folder

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

I would like to move my top zip file from downloads folder to another folder.

 

I can filter the zip files in the Get files in Folder action, and sort them based on creation date, how do I ensure my flow only picks up the top file to be moved. Is there  a filter function?

 

Thanks,

Brian

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    That depends on what you mean by the top file.  If you are sorting by creation date do you want the newest or the oldest file?  After you get your files from the folder in sorted order you can use the First() function on the array of files to select only the first file from the list.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @Pstork1, I would like to use the newest files, and I have used the Get files function and sorted the list from new to old based on creation date. Which particular action do I need to use to filter the first file?

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    It wouldn't be an action.  There is a function available in the Expressions tab of the dynamic content dialog.  YOu would use that to filter the array of files returned.  If I use the list files in a folder for OneDrive the code looks like this.

    first(outputs('List_files_in_folder')?['body/value'])

      You can use that directly where you want to access the file or drop it into a compose action. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @Pstork1 , I am new to Power automate desktop, so not really sure where I can execute this.

     

    Performed the following steps

     

    1) Get all files from folder, by get files action and sorted them based on creation date and is saved in a variable 'Files'.

     

    Want to move the first file from this variable into a different folder, but still not able to extract only the first file from the folder.

     

    Appreciate all your responses so far.

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    Sorry, I hadn't noticed this was Power Automate Desktop.  I was showing you things for regular Power Automate.  Let me take a look at PAD.  There should be a similar capability.

  • Verified answer
    Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    OK, I got it.  To get the first item in the list of files returned you need to include the index of the file when you retrieve it from the list variable.  So when I do Get files in folder it creates a variable called 'Files'. I can then use %Files% to get the whole list or %Files[0]% to get the first file in the list.

  • Jamar_Forsythe Profile Picture
    Microsoft Employee on at
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

     

    I am using a flow to select the latest file in a selection window.

    I have tried this and is able to get the latest file.

    However, the flow actually paste the file with the whole file path into the file name of the selection window.

     

    TanBoonChang_0-1699370211936.jpeg

     

    Correct me if I am wrong. From this, it seems that "%Files[0]%" contains the whole file path of the file (i.e. "C:\User\etc\file1.txt", instead of only "file1.txt") How do I extract the file name only, without the whole file path? Is there tools to cut particular portion from an obtained "%Files[0]"? Is this issue only occurring for the selection window which I am using?

     

     

    Best regards,

    Tan Boon Chang

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 275 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 235

#3
David_MA Profile Picture

David_MA 178 Super User 2026 Season 2

Last 30 days Overall leaderboard