cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pebkac03
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
ZachRoberts
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
ZachRoberts
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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (24,656)