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 / Building a flow to aut...
Power Automate
Unanswered

Building a flow to autofill metadata field from a SharePoint filename string

(0) ShareShare
ReportReport
Posted on by 34

Hello - I am completely new to the possibility of using Power Automate but I have a repetitive task for a migration project which Automate might be able to help with.

 

Uploading loads of documents to a SharePoint document library - they all have filenames like:

P.01.18.03.8139$8B1 Document Prevention.xlsm
Q.01.18.03.8140$8B1 Document Prevention - CL151E.xlsm
P.01.22.03.8162$High DP 8P3Y - CL151Q.xlsm
N 01.22.03.8163$8T108 Loss of Overturn - CL151R.xlsm
N01.17.04.2001$EZ2725 Proof Test Procedure.xls

 

The name consists of a reference code, then a $symbol, then the true filename.  I would like to automate the process of removing the string before the $symbol and placing into a metadata field called Reference Code, leaving just the true filename of the string after the $symbol.  At the moment, the files are waiting to be uploaded to the document library so I'm guessing that the workflow would start from that point.  Any help would be great.

 

Categories:
I have the same question (0)
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    Here are two expressions that will get the first Reference Code and second the File Name.

     

    I used a variable in my example, but you can replace that with your dynamic content.

     

    This will get the first part Reference Code:

     

    slice(variables('FileName'),int(0),int(indexOf(variables('FileName'),'$')))

     

     This will get the second part File Name with the extension:

     

    slice(variables('FileName'),add(int(1),int(indexOf(variables('FileName'),'$'))))

     

     

    Here are photo examples

    Slice FileName.pngResults Slice FileName.png

     

    If you just want the File Name without extension use:

    slice(variables('FileName'),add(int(1),indexOf(variables('FileName'),'$')),int(sub(int(lastIndexOf(variables('FileName'),'.')),int(1))))

    Here is a photo of that file name without extension:

    Get File Name without extension.png

     

    Let me know if this works for you

  • Overused Profile Picture
    34 on at

    Thank you for trying to help me - I have fallen at the first hurdle I'm afraid.

     

    This is a flow which would need to take place inside SharePoint so I don't know how to get "Initialise Variable" to pick up the library documents using your method?

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    Where are the files "waiting to be uploaded"? Are they on your OneDrive? Are they in another system?

  • Overused Profile Picture
    34 on at

    Thanks for responding.

     

    I was under pressure to upload the files so they are now in the SharePoint document library.

    At the moment, I have prepared three separate flows for the process:

    1.  Copy the filename into the Reference Code field

    2.  Slice the Reference Code contents and extract only the part before the $

    3.  Slice the filename contents and extract the part after the $ and rename the file with this part

     

    Thank you for your kind assistance with the slice process and I was able to use that in the flows.

    I have all the flows triggered only for 1 file which I select.  My next step is to combine the flows and get them to run on all the files in a folder.  Its a very slow process for me!

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