cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Pebkac03
Level: Power Up

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
ZachRoberts
Level 8

Re: how to use flow to sort onedrive files

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

2 REPLIES 2
ZachRoberts
Level 8

Re: how to use flow to sort onedrive files

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

Pebkac03
Level: Power Up

Re: how to use flow to sort onedrive files

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

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 104 members 3,936 guests
Please welcome our newest community members: