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 / How can I convert the ...
Power Automate
Answered

How can I convert the output of a "List files in folder" action from an object to an array?

(0) ShareShare
ReportReport
Posted on by 42

Hi. Very new to Power Automate and expressions. I am trying to get a list of files and folders in a target OneDrive folder and filter out the file names to end up with a list of folder names only.

 

The ultimate goal is to compare those folder names with a string extracted from an email (which I have figured out how to do), and IF there is a match, save the email as a .eml file into the folder whose name matches the word extracted from the email.

 

I've worked out a series of steps to achieve this goal, but I am currently stuck at filtering the list of files and folders... I need to convert the result to array first apparently, but I do not understand how to do that. I have asked Copilot but none of its solutions work. And everything I find online either doesn't work or isn't suitable for this task. Any help with this would be greatly appreciated!

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi ,  @DanJECC 

    According to your description, you want to convert the "List files in folder" action from an object to an array.

    This is my output of my "List files in folder" action:

    vyueyunmsft_0-1710725185867.png

    For example , if you want to make all the [Name] in an array , you can just use this expression:
    xpath( xml(json(concat('{"root":{"item":',outputs('List_files_in_folder')?['body/value'],'}}'))) , '/root/item/Name/text()')

     

    Then we can get an array of [Name]:

     vyueyunmsft_1-1710725342883.png

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

     

     

     

     

  • DanJECC Profile Picture
    42 on at

    Ahh, excellent. Is there a way to simultaneously filter the list of names to only include the folder names? Or does that require an additional step?

  • Verified answer
    v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @DanJECC 

    If you want to just extract the folder names like this:

    vyueyunmsft_0-1710726375373.png

     

    You can try to use this expression:
    xpath( xml(json(concat('{"root":{"item":',outputs('List_files_in_folder')?['body/value'],'}}'))) , '/root/item[IsFolder="true"]/Name/text()')

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

     

     

  • DanJECC Profile Picture
    42 on at

    Amazing! That does exactly what I need to do. Next step is to string match that output to see if a specific folder exists, but I think I have what I need for that. Thank you very much for your help.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 785

#2
Valantis Profile Picture

Valantis 669

#3
Haque Profile Picture

Haque 563

Last 30 days Overall leaderboard