Showing results for 
Search instead for 
Did you mean: 
New Member

Gather Files from Directory and SubDirectory(s)

Is it possible to do the following?


Working with OneDrive Business for all File locations.


End Goal - >  From Folder / Directory Location.  Gather a List of all the files in this location and generate a Table listing the file information. 


  1. Option 1
    • Get a List of all files at a location including any that are within folders (This option it would appear is not possible?)
  2. Option 2
    • Get a List of Files at a Folder (Simple Enough)
    • From the Above List Gather the "Path" of each folder in the above items (This is the Stuck Point)
    • Get a List of Files from a Path (as created in the previous step.)
    • Gather Name and File Type for each file and write to a CSV file (Simple to complete)

The Issue I'm running into.  It appears the simplest way to gather a file name or Path is to "Initialize a Variable"  However where I get stuck is this will only work on a single file and not a list of files.


Error Message Received  "The variable action 'Initialize_variable' of type 'InitializeVariable' cannot be nested in an action of type 'Apply_to_each'."


Any assistance would be appreciated.  




Community Support
Community Support

Hi @mengelmn,


I did a test on my side. If the Dynamic content is configured in the "List file in folder" action, Flow does not work.

It is currently not possible to get the files under the subfolders in the way you mentioned.

There is an action that only gets the files in the current folder. I am afraid I can't implement your needs at present.

If you want to get the files under the subfolder, this function is supported by Flow.Please consider submit an idea in the Microsoft Flow idea forum:

In addition, if you want to use variable storage file information, you could use Append array to array variable to achieve, you could refer to the following Flow configuration:


Best Regards,


Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,323)