Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

condition: only if file name equals folder name

Hi everyone, 


I would like to do the following but haven't been able to figure it out.

I want to have a condition where it's if file name equals folder name then yes (if no, no action to be taken).

In a previous flow I created a folder in library 2 when a file was uploaded in library 1 and then moved the file to the new folder (which is named the same as the file), in that folder.


Now, I want to use that folder so people can upload additional documents to it.

But I also have a flow where an item is added or updated in a list if a file is created or modified. 

However, I only want an item created or updated in the list if that file has the same name as the folder.

So that no item is created for supporting documents (like e-mails) but only for the first file created in the folder which happens to have the same name as the folder.


Thanks in advance for the help!

Best regards,


Super User
Super User

Re: condition: only if file name equals folder name

Hi @LauraHill 


Believe you have a document library with multiple folder names. What you want is to check whether a folder already exists in a document library using filename (Dynamic value)? Is that you looking for?



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up

Proud to be a Flownaut!

Level: Powered On

Re: condition: only if file name equals folder name

Hi @abm 


Not exactly, I do have a library with multiple folders and I want to create a flow using a condition 'if filename = foldername'. However I'm not sure if this is possible. Because I don't want the flow to work whenever a file is created or modified, only if the file happens to have the same name as the folder. 


Best regards,


Community Support Team
Community Support Team

Re: condition: only if file name equals folder name

Hi @LauraHill,


One question, if multiple files with the same name, how do you want to process it?


I have an idea that when a file upload in library A, then create it in a folder name same with the file in library B, for example:

First step should do is separate the file name and extension by using split() function, split by '.', it will get an array, the file name is the first member, so use '0' as the index to get it:


Then Get file content and create file, the folder path is Library/FileName.

Annotation 2020-01-06 154646.png

Hope it could help you with something.

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

Level: Powered On

Re: condition: only if file name equals folder name

Hi  @v-litu-msft,

I'm not sure I understand your explanation, my apologies. 


I already have a flow which creates a new folder with the same name as the file and then it moves the file under that folder.

What I would need, is to create a new flow that works IF: 'when a file is created or modified' the file name equals the folder name. 

Alternatively, if this is not possible, to identify the first file added to a new folder and only have that file be added to a list.


For visualisation, what I'm trying to achieve (bold I don't know how to yet)

1) a person uploads a file in library A

2) folder with name of file is created in Library B and file is moved to that folder, so that library A is empty (so it works like an upload center, without others being able to see which files are added).

3) The person has access to the folder only (not the whole library B) and can add additional files to the folder, such as supporting e-mails.

4) The original file (one with same name as folder) only is copied to a list, which is then used to create graphs. Not the additional data.


I am able to copy it to a list, but currently it copies all files instead of only the one that matters. 

Ways I think it could be solved (but not sure how to execute it)

  • Add condition that only file with same name as folder to be added/updated in list
  • People have to change properties of the file and only copy items to list if one of the columns in Library B is not empty
  • Add condition that only first file to be updated in list (as the file I need to copy is always added as first item in folder)
  • Add condition that only modified files can be added to list (however danger that people might modify the wrong file and then it's added to the list as well).

If this is not possible, I will either create a new document library for supporting documents OR not give the ability to people to add additional files in document Library B OR copy the file in two librarys (B and C) and have C be hidden and only used by owner of the SharePoint page. 

I'm not sure which solution is best.


Thank you everyone!

Best regards,



Level: Powered On

Re: condition: only if file name equals folder name

Hi everyone, 


Just to inform you I have created a work around for my case. I'll explain it shortly, in case it's useful for others as well.

Also a thank you for trying to help me figure this out!


The original goal: use a condition 'IF folder name = file name, then copy to list.

However, now I have adapted the flow as follows, I created an extra column in the document Library B (where the file was moved to under the folder). Then I added the action, change file properties, to fill out the column. 

Then in a second flow I added the condition if column is not empty, then move to list. 


This way only the file which was uploaded in document library A, which then using a flow moves to document library B is added to the database list. This way people can add supporting documents to the folder, but are not added to the list.


Helpful resources


Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!


Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!


New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (3,792)