cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Spoloshy
Frequent Visitor

For a Selected File List Files in Same Folder

Hi, I am having trouble with the 'list files in folder' or perhaps the 'find files in folder by path' connection.

 

When I trigger power automate using a certain file, what I'd like to do is have power automate search the same folder my file is in to find a corresponding excel document which is in the same folder. e.g.

 

Trigger file: 12345 - Overview.docx

(other stuff happens)

Finds: 12345 - Reviews.xlsx

Send Email, attach 12345 - Reviews.xlsx

 

However, I am struggling to search in the folder because the path I am working with is the file path. Other guides suggest using a fixed folder path but this won't work for my file structure.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Spoloshy
Frequent Visitor

I have now solved this problem.

 

First I find the file path by altering the string of the original file, firs

t using:

LastIndexOf(outputs('Get_file_metadata_using_path')?['body/Path'], '/')

 

substring(outputs('Get_file_metadata_using_path')?['body/Path'],0,add(outputs('Compose'),1))
 
This returns the folder path of the file:
/Projects/AuthorName/Production/
 
This then enables me to use 'List all Files in Folder'. I then use a conditional to check if the file I want contains a keyword in the title.
 
I then set a variable using the single positive result this should return.
 
This variable is used as a path to find the content and metadata and attach it in my email.
 
 
 

View solution in original post

7 REPLIES 7
v-qiaqi-msft
Community Support
Community Support

Hi @Spoloshy,

I have seen that you have a same thread here that have been solved.

Have you solved it?

 

Best Regards,
Qi

Hi Qi, yes my previous problem has been solved but this ticket is raising a different query (as far as I know!)

Hi @Spoloshy,

Sorry for the late reply.

Do you want to select a file to trigger the flow and search another file within the same folder so that you could send this file in an email?

If so, I have a test on my side, please take a try as below.

Not sure how you determine the file path, I find the file path as below.

vqiaqimsft_1-1626665257869.png

vqiaqimsft_0-1626665203083.png

Check if this could help you.

 

 

 

Best Regards,
Qi

Hi Qi,

 

Yes that's the action I wish to take!

 

Is there an equivalent of this with OneDrive for Business? Currently I use:

 

For a selected file -> Get file metadata using path -> Get file content using path

 

Best,

Michael

Hi @Spoloshy

If you use the OneDrive connector, please modify as below:

vqiaqimsft_0-1626847534545.png

vqiaqimsft_1-1626847587204.png

Check if this could help you.

 

 

 

Best Regards,
Qi

Hi@v-qiaqi-msft - sorry I don't think I've explained myself well enough.

 

Currently I have the below actions:

 

filepath.PNG

 

This file is always labelled with a variant of: 12345 - PQ.docx

 

What I would like to do is find the file in the same folder as this file: 12345 - Writeup.xlsx

 

I tried trimming the first file name to reduce it to just 12345 and then use Find Files in Folder within OneDrive, but that never returned any results.

 

I then need to attach these two files in two different emails later on in my flow.

Spoloshy
Frequent Visitor

I have now solved this problem.

 

First I find the file path by altering the string of the original file, firs

t using:

LastIndexOf(outputs('Get_file_metadata_using_path')?['body/Path'], '/')

 

substring(outputs('Get_file_metadata_using_path')?['body/Path'],0,add(outputs('Compose'),1))
 
This returns the folder path of the file:
/Projects/AuthorName/Production/
 
This then enables me to use 'List all Files in Folder'. I then use a conditional to check if the file I want contains a keyword in the title.
 
I then set a variable using the single positive result this should return.
 
This variable is used as a path to find the content and metadata and attach it in my email.
 
 
 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (3,866)