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 / To copy only the 1st f...
Power Automate
Answered

To copy only the 1st files in a list/Or to copy file from the last modified folder?

(0) ShareShare
ReportReport
Posted on by 16

Hello guys, I'm trying to find a solution to this:

 

I'm having a General folder including multiple folders for different week, named as: YYYY.MM.DD and I'm trying to copy the last report (named as Inventory....) to a new created folder each week.

I'm thinking of either 2 these solutions:

1. To "Copy files" named Inventory* from the "Last modified folder" to the new created folder

-> But honestly, I don't know how to "call out" the last modified folder in Power Automate Desktop. The only action that produce a "folder" variable here is the "Get special folder" - which doesn't allow me for "Advanced parameter/selection" like the action "Get files in folder" or "Get subfolders in folder"; but the later 2 produce "a list of folder" which cannot be used with "Copy files"

Get subfolder.jpg

I believe the "Advanced" here is the answer to my solution, but unfortunately, this action "Get subfolders in folder" produce a "list of folder" as variable; instead of "folder" and thus I cannot refer to it when using "Copy files" action.

 

2. Use "Get files in folder" to generate a list of files that match the criteria as "Inventory xx"; and then use "copy files" but ONLY COPY THE FIRST FILE in the list (like last modified)

-> But under this, I don't know how I can "copy" only the 1st file in the list, either.

Automate.jpg

 

I look for a similar solution here: Solved: Is it possible to copy/move only the most recent f... - Power Platform Community (microsoft.com) but somehow my Action "Copy files" doesn't give me any "advanced parameter" as suggested in the post (as you see in my screenshot above)

 

I'm very new to Automate so plz forgive if above question is silly 🙂

Thanks & best regards,

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    When you have a list in the proper order, you can use the syntax %List[0]% to specify the first folder (or file) in the list. 

    best of luck!

  • cpkhoi Profile Picture
    16 on at

    It worked perfectly, OMG thank you so much. Such a simple tool.

     

    And sorry to bother you again, what is the syntax for the "last" of the list, and where can I find other kinds of syntax to learn and use them?

     

    Thank you again Michael 🙂

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    So, that takes 2 steps. The [0] is the first item because it is a 0 based index. 0 is the first, 1 is the second and so on. 

    you can get the count of items in a list by %List.Count%.  So, if there are 3 items in a list, this would give you 3, but the index is always -1. 


    so the index of the last item is %List.Count - 1%

    So, you can string it all together:

     

    %List[List.Count - 1]%

     

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 227 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 213 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 151

Last 30 days Overall leaderboard