Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Splitt filenames in SharePoint Library

(0) ShareShare
ReportReport
Posted on by 91

I have a flow that separates the file name after an underscore. The first 7 digits are the part number, after the first underscore comes the color number and after the second underscore comes the format. Using the split function with split(variables('String'),'_')[0] I split the name of the document with split(variables('String'),'_')[1] split(variables('String'),'_')[2] and transfer the value from the "Format" field to the "Status" field of the Sharepoint document library. This works perfectly for filenames that are 1017277_31390_7 15 digits long.

But now I want to transfer a value to the Status field also for file names 1021114_10332 which have only one underscore and are 13 digits long, in this case the status should have the value "99". It would be perfect if the condition can be checked that only documents with the extension .png and .jpg are processed.

Translated with www.DeepL.com/Translator (free version)Trigger.png

Flow Part II.png

Flow Part I.png

Library Pictures.png

  • TomTT Profile Picture
    91 on at
    Re: Splitt filenames in SharePoint Library

    Hi @tom_riha 

     

    it works perfectly, thank you very much

  • Verified answer
    tom_riha Profile Picture
    10,127 Most Valuable Professional on at
    Re: Splitt filenames in SharePoint Library

    Hello @TomTT ,

    to run the flow only for .png and .jpg files you can use a trigger condition - check if the file name ends with the .png or .jpg string and run the flow only if true.

    @or(endswith(triggerOutputs()?['body/{FilenameWithExtension}'], '.png'),endswith(triggerOutputs()?['body/{FilenameWithExtension}'], '.jpg'))

    For the file name you can adjust just the 3rd expression. Instead of automatically taking the 3rd part of the split

    split(variables('String'),'_')[2]

    you can combine it with the if(...) expression to check how many parts the string has. If it has 3 pieces, it contains also the 3rd part. If it's less than 3 pieces then there's no 3rd part and use the value 99.

    if(equals(length(split(variables('String'),'_')),3),split(variables('String'),'_')[2],'99')

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1