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

Sort files into specific SP library folders - if a folder name not found a new folder is created

Dear developers, 

I would have a question, please refer to the step #3 in my flow design below. 

 

I am building a flow which would extract SP list attachement(s) and copies them into a general folder. A 2nd flow should move files from a general library into specific folders based on file names. 

 

  1. Power App form creates a SP list item with attachment.
  2. Power Flow extracts the attachment(s) and creates files with naming convention "AppSubmitterName_AttachmentName" (AppSubmitterName can be a random person's full name) in a general SP Document library.
  3. 2nd flow will trigger a new file in the folder, then reads the AppSubmitterName (the part until'_' from the original file name) and moves the file to a folder named AppSubmitterName. And now the tricky part, IF the folder with the AppSubmitterName does not exist in a document library the flow creates a folder named AppSubmitterName and moves the file into it.

 

I am not sure whether the 3rd step is technically buildable.

Thank you for comments. 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User III
Super User III

Hi @mesan123 

 

 

Please follow the below steps

 

image.png

 

Above compose expression is as follows:

 

first(split(outputs('Compose_2'),'_'))
 
Also watch my video tutorial regarding file move.
 


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!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

5 REPLIES 5
abm
Super User III
Super User III

Hi @mesan123 

 

 

Please follow the below steps

 

image.png

 

Above compose expression is as follows:

 

first(split(outputs('Compose_2'),'_'))
 
Also watch my video tutorial regarding file move.
 


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!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

mesan123
Frequent Visitor

Hi @abm ,

Thank you very much for this design.
I was wondering whether a 'folder existence check' condition can be added into your flow in order to determine the folder with the name already exists or not in the library (it can happen that the same person submits more app records which would cause folder name duplicates or flow fail).

Something like after 'Compose' action where we extracted the folder name to put a condition for folder existence check based on the name. If the folder exists -> do a Move file into it, if not perform the Create new folder and move file into it.

Thank you for suggestions.

abm
Super User III
Super User III

Hi @mesan123 

 

Thanks for your reply.

 

You can use the create folder action step without checking whether folder exists or not. If folder already exists it won't recreate the folder. If you want explicitly check then please see my blog link below.

 

https://mydevexperience.wordpress.com/2020/02/08/power-automate-how-to-find-a-folder-exists-dynamic-...

 

Thanks

 

 



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!

Learn more from my blogPower Automate Video Tutorials
mesan123
Frequent Visitor

Hi @abm , 

Thank you for your explanation and help on this design. 

 

Am I right in my understanding of your comment that if the folder already exists the action step 'Create a folder' will not create a duplicated folder and the action step 'Create a folder' will be passed as successful without any action done and the file will be moved in the subsequent action step into it. 
And this way the initially created folder will absorb new and new attachments if the same person submits the app again (the folder to be named always as the appsubmitter). 

 

Thank you once again.

mesan123

abm
Super User III
Super User III

Hi @mesan123 

 

Yes that's my understanding. 

 

Thanks



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!

Learn more from my blogPower Automate Video Tutorials

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (61,735)