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 / Get substring from fil...
Power Automate
Unanswered

Get substring from file name and move to matching SharePoint Online folder

(0) ShareShare
ReportReport
Posted on by 68

Hi,

I'm having difficulties trying to achieve the following scenario using Power Automate - I have a document library holding many folders. Each folder is named after an individual employee and her/his ID number, for instance John Doe, 1111111, the ID will always come after a comma, or some other separator. There is another document library, to which files for these employees will be uploaded. The file names will contain the name and the ID of the employee. Now what I'm trying to achieve and create an automation for is, to get the ID number out of the name of the file as it'll always be unique, out of the whole string, then look for the folder in the first document library holding all user folders containing this substring and based on that, to move it to that folder that matches the ID substring. Any help/ideas will be very much appreciated.

Categories:
I have the same question (0)
  • v-litu-msft Profile Picture
    on at

    Hi @benny_blanco,

     

    You could use the split() function to convert the file name into an array, for example:

    split('John Doe, 1111111',',')

    The result will be:

    [

    "John Doe"

    "1111111"

    ]

    Then you could use last() function to get the "1111111", for example:

    last(split('John Doe, 1111111',','))

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • benny_blanco Profile Picture
    68 on at

    Thank you for the formula! Replaced the name and ID part with the dynamic value of the actual document name and it is separating and returning everything after the separator. Any ideas on how to make it look for the one folder that contains the same ID information and to move it there automatically?

  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @benny_blanco,

     

    Yes, after you get the ID, please refer to the following steps:

    Annotation 2020-05-08 172205.png

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • benny_blanco Profile Picture
    68 on at

    Thank you for that! Let me test and will let you know.

     

    Cheers!

  • benny_blanco Profile Picture
    68 on at

    Hi @v-litu-msft ,

     

    Thank you, it worked! 

     

    Something else I want to ask though about the formula you provided - it gets everything after the separator, but gets the file extension as well (.pdf, .docx). How can I make it work without getting that part, the file extension?

  • v-litu-msft Profile Picture
    on at

    Hi @benny_blanco,

     

    Use the split() function again, separate by ".", for example:

    first(split('1111.excel','.'))

    It will return: 1111

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • benny_blanco Profile Picture
    68 on at

    @v-litu-msft  - Can I ask you for some help again as I can't figure it out. It turns out the actual string looks like this -

     

    JonasSmith-Joe-1234567-CLMPDVVD-TB.pdf

     

    and I need to extract only the ID part, only the digits you see and then look for that ID in the folders, if they contain it. How can I extract the ID alone first, then the name at the beginning alone again? Thank you for the support!  

  • v-litu-msft Profile Picture
    on at

    Hi @benny_blanco,

     

    Use the split() function could do it:

    split function could separate a string by a substring, convert it into an array, then index could extract member of the array:

    split(outputs('Compose'),'-')[2]

    Annotation 2020-06-05 153814.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • benny_blanco Profile Picture
    68 on at

    Thank you as usual! Will try it and let you know.

  • benny_blanco Profile Picture
    68 on at

    @v-litu-msft -Thank you, works perfect and depending on the digit inside of the brackets, I can manipulate what to return, after which - sign.

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard