cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HRice
New Member

How to move file to specific folder where file and folder contain specific text (Staff Initials)

I am a complete newbie to Power automate and I am hoping this is possible. I am in desperate need of getting my files organised as taking over as manager soon and would like to have some systems in place ready.

 

I am wanting to organise staff files, so If I save a document containing staff initials (e.g. SK) I would like it to automatically move to the Staff Folder named the specific intials (e.g. SK)

 

So if I save a file SK New Starter checklist.jpeg it would automatically move it to the folder named "SK"

 

We have about 25-30 Staff members, do I have to set up a new flow for each set of initials or can I just set it so any 2-3 letters in caps is recognised if it has a folder matching those letters?

 

I hope that makes sense, Thanks in advance for your help

2 REPLIES 2
HRice
New Member

I forgot to add the files are all saved in Onedrive 

eliotcole
Super User
Super User

You can set it on one flow, which I'll get to in a second ... but might I suggest a non-folder based suggestion for your incoming files?

 

First of all, I'd suggest using your own library inside a relevant SharePoint group, this will much more easily allow you to assign permissions for others to access it programatically in the future. You can keep general staff out, for example, but allow your seniors, or relevant staff, to have access where needed.

 

Even if you don't, a specific library for the files would be a good idea.

 

Why a library? Well, because you can add "metadata" columns to the library that allow you to better define what any file within it is all about. For example, like any SharePoint list, you can create a 'People' column, which you could then assign ... yep ... the person whose file it is.

 

Once you have that people column, then you can easily organise, find, etc, all files that have that particular user in the People column that you've created. Plus, if you still want to have folders, you still can! You can even assign a 'People' value to the folder, but also everything within.

 

ANYWAY ... to directly answer your question, yes, it's relatively easy. I'll edit in images, and anything else needed, but essentially

  1. Make the flow trigger a new sharepoint/onedrive file
  2. Make two parallel branches:
    1. One Side:
      1. get files in that folder or library
      2. filter either by ODATA (on ContentType eq 'Folder') or a Filter action on IsFolder equal to true
    2. Second side:
      1. Use a split() on space in the filename of the created file.
      2. Either use first() or [0] to get those first two letters.
  3. Run a filter action the list of folders from the first side, filtering by folder name and if that equals the letters you got from the filename
  4. Condition on the number of responses in that filter is greater than 0
    1. if true/yes take the first item from the filter and place the file in that folder
    2. if false/no, make the folder and place it in there.

 

That looks complicated as a list of stuff to do, though technically it's just 4 steps, but when I plot it out you'll get it. 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,117)