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 / Scan an incoming folde...
Power Automate
Unanswered

Scan an incoming folder, and move files based on filename to folders with same name

(0) ShareShare
ReportReport
Posted on by 18

Hi everyone,

 

I'm still very new to Flows, and I'm trying to automate some document filing.

 

We've got a sharepoint library folder where PDFs get dumped with client names included in the file name.  I'm trying to design a flow that will check that folder say once an hour (or even just once a day), then look in another folder at all the subfolders and find a folder that contains a name that's on the filename of the PDF.

 

It definitely won't be able to find a match on every one, which is ok, but even if it can file 75% of the documents there it will help.

 

So the PDF name is something like 2019_April_AS_CLIENTNAME  and then the folder contains a whole ton of folders that are the client name.  And we want it to file the document something like CLIENTNAME FOLDER/DOCS/2019 or similar...

 

It's based on financial year, so we can't just the year necessarily at the beginning of the file name.  But I can tailor that if I can get the scanning and recognising working first...

Categories:
  • vecerpa Profile Picture
    786 on at

    Hello @Charlesk have you already build something?

     

    I do not have same case running but I beleive that we can achieve it as I am also using listing all items in document library and looking for folder names.

    P.

  • v-zhos-msft Profile Picture
    Microsoft Employee on at

    Hi @Charlesk ,

    It seems you want to move the PDF file to the corresponding folder.

    I have made a test on my side, please take a try with the following workaround:

    In my SharePoint, there are two libraries, lib1 and lib2.

    I uploaded the PDF file in lib1, then move the file to the corresponding folder in lib2.

    The file in lib1:

    Capture9.PNG

    The folder in lib2:

    Capture10.PNG

    Expression in Compose 2: last(split(outputs('Compose'),'_'))

    Capture7.PNGCapture8.PNG

     

     

    Best Regards,

    Community Support Team _ Zhongys

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Charlesk Profile Picture
    18 on at

    @v-zhos-msft  Hmmm, thanks.  Rather than just copying in a demo sharepoint I want to try to understand it.

     

    Can you please explain how that's working? I don't quite understand the Compose or the Last(split...  etc component.  Do you mind please explaining it in words for me?

  • v-zhos-msft Profile Picture
    Microsoft Employee on at

    Hi @Charlesk ,

    As the pic showed, the Compose action is to get the file name(2019_April_AS_CLIENTNAME).

    The expression in Compose 2 is to get the CLIENTNAME.

    split(outputs('Compose'),'_') will return an array ['2019','April','AS','CLIENTNAME']

    Last() will return the last element of the array.

    For more information about the function, please take a reference below:

    https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#string-functions

    Best Regards,

    Community Support Team _ Zhongys

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Charlesk Profile Picture
    18 on at

    Thanks @v-zhos-msft 

     

    Do you think a "contain" function would be able to match say the first 5 characters of CLIENTNAME on the file to the first 5 characters of the folder name to find a match?

     

    IE we don't need an exact match, but the first 5 characters only?

     

    The issue is that the file name is often CLIENTNAME, but the folder name is CLIENT NAME.  It's too hard to rename all the client folders to remove spaces etc...

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, 

     

    I copied your flow but it does not work for me. 

    The expression result is always false and it always gives me this error. 

    "ActionFailed. An action failed. No dependent actions succeeded."

     

    Any help? 

     

    Regards

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 430

#2
11manish Profile Picture

11manish 341 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 282

Last 30 days Overall leaderboard