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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Moving files from a Sh...
Power Automate
Unanswered

Moving files from a SharePoint folder to other SharePoint folders depending on filename

(0) ShareShare
ReportReport
Posted on by

I have a General SharePoint folder that has several PDFs in it. I want to write a flow that moves them into other folders, depending on their name, so for example:

 

111-Exeter.PDF will move to EXETER Folder

1352-Coverntry.PDF will move to COVENTRY folder

and so on...

 

I have more than 40 different folders. I tried using a a condition (i.e., If it contains Exeter move to Exeter, if it doesn't, does it contain Coventry etc.) but this is no good because there is a limit I think of 8 so I would have to have more than one flow and the locations change all the time.

Categories:
I have the same question (0)
  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    Hello @DEBS1644 ,

    you don't need a condition, you can use an expression to define the folder dynamically. Since the folder name is in the file name, you just have to extract it from there.

    • remove the extension: split(fileName, '.')[0]
    • remove the number prefix:  split(split(fileName, '.')[0], '-')[1]

    that's the folder name which you can use as the destination folder.

  • DEBS1644 Profile Picture
    on at

    Hi, the example in the link is for moving files from an email attachment. How do I do it from another folder? Also, when removing the condition, do I need to replace it with an Apply to each, add the identifier as the output from previous step before I create the compose action to split the name?

    DEBS1644_0-1711019336680.png

    Apologies, but I'm new to Power Automate so have limited ability - find most of what I need by Googling or using this community.

  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    Hello @DEBS1644 ,

    the example shows you how to extract a part of file name. In your case you want to list all the files, loop through all the files, and copy them into a folder based on part of the file name.

    split(split(items('Apply_to_each')?['{FilenameWithExtension}'], '.')[0], '-')[1]

    the flow might look as below.

    image.png 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 573

#2
Valantis Profile Picture

Valantis 407

#3
11manish Profile Picture

11manish 387

Last 30 days Overall leaderboard