cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous5
Level: Powered On

Move file in Sharepoint to destination folder dictated by filename.

Hello all,

 

I've done a fair bit of searching for an answer on this one but so far have had no luck. I am curious if it is possible for Flow to take an action in Sharepoint to place a file in a library with nested folders and use filename to place the file in its final destination.

 

For example, within Sharepoint, I have a library to store vendor service reports (.PDFs). The folder structure from the intial library is: /(Site Name)/Service Reports/(Vendor Name). What I'd like to happen is for a flow to trigger when a new file is created in Sharepoint then move the file to its final home using the filename. If the filename is "PO12345_(Site Name)_Service Reports_(Vendor Name).pdf" it would land in the proper folder 3 levels down as described above.

 

I've seen various methods of trying this using the "split" function and "compose" function but most of these are perhaps one folder deep. What I think needs to happen is that the file name needs to be parsed (using underscores,periods, etc.), then reassembled with slashes to create a filepath. Perhaps this is too complex to accomplish but any help would be welcome!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Move file in Sharepoint to destination folder dictated by filename.

 

Hi @Anonymous5 ,

 

Do you mean to move a file with a specified name to the folder hierarchy contained in the name?

If so, you can refer to the following methods to achieve your needs.

First, use the split () function to remove the extension, the result is an array, and then use index to get the name of the specified folder.

Then configure the path to the destination folder, first populate the Library Name, and then configure the Folder path based on the folder name contained in the file name.

Expression reference:

split(first(split(body('Create_file')?['Name'],'.')),'_')

Image reference:

179.PNG180.PNG

 

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.

View solution in original post

4 REPLIES 4
Community Support Team
Community Support Team

Re: Move file in Sharepoint to destination folder dictated by filename.

 

Hi @Anonymous5 ,

 

It should be noted that the Destination Site in the Move file action is selected directly from the drop-down list.

The structure in the Destination Folder is in the format "/LibraryName/FolderName", which can be configured by manually entering the folder name.

Your idea is roughly correct. Use the split() function to split the File name and get valid information, and configure this information in the Destination Folder.

 

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.
Anonymous5
Level: Powered On

Re: Move file in Sharepoint to destination folder dictated by filename.

Hi V-Bacao,

 

Thank you for the reply. To be clear, I'm looking for more of a dynamic solution here. 

 

As an example, please see the example folder structure below. What we have in Sharepoint would be roughly simliar:

 

>SharePoint Library

  • Work Site A
    • Service Reports
      • Vendor 1
      • Vendor 2
      • Vendor 3
  • Work Site B
    • Service Reports
      • Vendor 1
      • Vendor 2
      • Vendor 3

 

If a new service report comes in as an Outlook attachment (PDF), can that file be titled by us something like:

 

"PO 12345_Work Site A_Service Reports_Vendor 1.pdf"

 

Can MS Flow see this file when it is created, use the file name information and construct a file path to move that file to a destination folder in Sharepoint? This would be a completely dynamic function. We receive several of these service reports a month and they get filed in different folders in Sharepoint as laid out above. For now this is a completely manual process.

Community Support Team
Community Support Team

Re: Move file in Sharepoint to destination folder dictated by filename.

 

Hi @Anonymous5 ,

 

Do you mean to move a file with a specified name to the folder hierarchy contained in the name?

If so, you can refer to the following methods to achieve your needs.

First, use the split () function to remove the extension, the result is an array, and then use index to get the name of the specified folder.

Then configure the path to the destination folder, first populate the Library Name, and then configure the Folder path based on the folder name contained in the file name.

Expression reference:

split(first(split(body('Create_file')?['Name'],'.')),'_')

Image reference:

179.PNG180.PNG

 

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.

View solution in original post

Anonymous5
Level: Powered On

Re: Move file in Sharepoint to destination folder dictated by filename.

Thank you Barry,

This solves my issue.

Rgds,
Rob

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 357 members 3,676 guests
Please welcome our newest community members: