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

Notifications

Announcements

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

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

I have the same question (0)
  • Pstork1 Profile Picture
    68,717 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
    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
    68,717 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
    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
    68,717 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
    68,717 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

    Variable manipulation and the % notation - Power Automate | Microsoft Learn
    Variable data types - Power Automate | Microsoft Learn

    These are some good links to help get familiar with Variables.

  • Community Power Platform Member Profile Picture
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard