web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Automations to file do...
Power Automate
Unanswered

Automations to file documents based on file name

(0) ShareShare
ReportReport
Posted on by 12

Hi all,

     We are trying to automate the filing of incoming documents into Sharepoint into specific folders based on the naming convention. For example, all incoming documents have the following naming convention "YYYY.MM.DD_Name_Type" and we would like to deposit these documents into a staging folder in our SharePoint site and then have the automation place them in the correct folders so if the Name is x put it in x folder and if type is y put in x folder then subfolder y. The issue is due to the amount of folders (Names) we have it would be well over 1000 individual automations if we have to specify the destination folder so I need the flow to fill in the destination folder based on the document Name. 

 

    I have been attempting to use 'Compose' with the split command to identify the name but am not having any luck.

 

Thanks in advance for any insight.  

Categories:
I have the same question (0)
  • Rhiassuring Profile Picture
    8,690 Moderator on at

    Well, let's start with the beginning, the easiest part. "Name". Does "Name" ever have spaces in it? Like, can it be "Pancakes Incorporated" or will it just be PancakesIncorporated? 

  • grantjenkins Profile Picture
    11,063 Moderator on at

    As mentioned, we would need to know if the Name and/or Type can have spaces. This would determine the approach necessary.

     

    Also, would you have a Library with the top level folders be your Name folders, and subfolders beneath these as your Type folders? Or is there a more deeper folder structure required?

  • CU21021532-0 Profile Picture
    12 on at

    Thanks for the responses all. So after playing around with the split command and due to your posts since the names will have spaces in them, and given the fact we can edit our naming convention easily, I now have the document names as "YYYY.MM.DD_Name_Type" with an "_" as the separator. The names could be upwards of 3-4 words and the type at max will be 2 words. 

     

    The folder structure is as follows:

    All documents are coming in from an automation from box into a folder called "Staging" at the top folder level of our Sharepoint site. The other top level folder is called "General" and contains all the Name folders and then each name folder contains the type folders (the type folders are identical across all the names). 

     

    Screenshot 2023-11-22 080148.png

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    Hopefully this will get what you're after.

     

    For this example, I'm using the following folder structure.

    grantjenkins_0-1700837616166.png

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_1-1700837657443.png

     

    When a file is created (properties only) triggers when a new file is uploaded into the Staging folder. Your folder structure will likely be different to this.

    grantjenkins_2-1700837701901.png

     

    Name and Type are Compose actions that retrieve the Name and Type using the following expressions. Note that this assumes the file name structure you mentioned. "YYYY.MM.DD_Name_Type"

    //Name
    split(triggerOutputs()?['body/{Name}'], '_')[1]
    
    //Type
    split(triggerOutputs()?['body/{Name}'], '_')[2]

    grantjenkins_3-1700837813704.png

     

    Create new folder Name and Create new folder Type try to create the folders. If they already exist the it won't do anything, but if they don't exist they will be created. Note that they use the outputs from Name and Type.

    grantjenkins_4-1700837893124.png

     

    Move file uses the Identifier from the Trigger and Full Path from Create new folder Type.

    grantjenkins_5-1700837995899.png

     

     After uploading a file into the Staging folder, it should be moved into the Name/Type folder.

  • CU21021532-0 Profile Picture
    12 on at

    Thank you so much for your help, I can't begin to tell you how helpful this is!

     

    After a few tests it seems to be properly moving the document into its appropriate folder perfectly!

     

    Thanks again for your help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard