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

how to use flow to sort onedrive files

I am currently trying to build a flow where I list all files in the root folder and then use apply to each to move them to a designated folder depending on which keyword the filename contains. for example, if I have one file named: "(Maths)the knapsack problem" and another named: "(English)the history of the English language" I want the maths-document to go into the maths folder and the English document to go into the English folder.

I am currently lost on how to get the flow to check if the name of the current file in the apply to each contains the keyword and then also if it's a file and not a folder and then moving it to the right folder.

1 ACCEPTED SOLUTION

Accepted Solutions
Resolver I
Resolver I

Hello @Pebkac03 ,

 

I have this figured out! Please follow the steps below to get this working for you. 

 

I used a different split in my file names, i named them like 'English,Test1' using the comma is what we will use to split the string and use that to select which folder the file needs to go to. 


Screenshots below are of the flow

Flow,onedrive.png

 

flowonedrive2.png

 

If the item is a folder set your 'Yes' condition to do nothing

flowonetrue.png

Then if the item is a file we want to do the following in the 'No' condition

flowno.png

 

Expression for the Compose step

split(items('Apply_to_each')?['NameNoExt'],',')

Expression for the Set Variable step

first(outputs('Compose'))

Screenshot below of the Switch step

flowswitch.png

 

For each folder you want to use to organize you can add a new Case to the switch step which compares the value of the FileType variable to the first part of the file name. 

 

Thanks,
Zach

View solution in original post

2 REPLIES 2
Resolver I
Resolver I

Hello @Pebkac03 ,

 

I have this figured out! Please follow the steps below to get this working for you. 

 

I used a different split in my file names, i named them like 'English,Test1' using the comma is what we will use to split the string and use that to select which folder the file needs to go to. 


Screenshots below are of the flow

Flow,onedrive.png

 

flowonedrive2.png

 

If the item is a folder set your 'Yes' condition to do nothing

flowonetrue.png

Then if the item is a file we want to do the following in the 'No' condition

flowno.png

 

Expression for the Compose step

split(items('Apply_to_each')?['NameNoExt'],',')

Expression for the Set Variable step

first(outputs('Compose'))

Screenshot below of the Switch step

flowswitch.png

 

For each folder you want to use to organize you can add a new Case to the switch step which compares the value of the FileType variable to the first part of the file name. 

 

Thanks,
Zach

View solution in original post

Thank you, this will make my studies so much easier!

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (71,462)