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

Move Files between Folders based on File Extension

 

Using Power Automate Desktop, how to I create a flow to move files between folders based on file extension? 

 

For example, I want to:

  • Move all .xlsx files into Folder 1.
  • Move all .ppt files into Folder 2.
  • Move all .pdf files into Folder 3.

 

Hope anyone can advise, thanks! 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Henrik_M
Continued Contributor
Continued Contributor

There are two main methods:

 

Method 1 - Get set of files by extension, and move them all

You will need to Get files in folder with a file filter, and then Move files the %Files% variable.

3 times, so 6 actions in total.

 

Method 2 - Get all files, and loop through to move by extension

You will need to Get files in folder without a file filter, and then a For each loop.

In the loop, you can then use If conditional to check if %CurrentItem.Extension% equals .xlsx and so on.

1 loop, 3 conditional blocks, so 11 actions long in total.

 

Method 1 is cleanest, but method 2 is more versatile if there are more parameters of the files to be considered.

View solution in original post

5 REPLIES 5
DiegoEscobar1
Frequent Visitor

Hello @superbackhand . You can use the trigger "When a file is created in a folder" and then use the "Switch" control comparing with the content-type output from the trigger (@{triggerOutputs()?['headers/Content-Type']})

Here is the flow:

DiegoEscobar1_0-1618775862099.png

And here, the contect-type to compare with:

  • ppt: application/vnd.openxmlformats-officedocument.presentationml.presentation
  • xlsx: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • pdf: application/pdf

I used the notifications actions instead of the the "Move File" action below, just for simplicity.

 

DiegoEscobar1_1-1618776138788.png

 

 Hope it helps!

 

Regards.

Diego.

  

Henrik_M
Continued Contributor
Continued Contributor

There are two main methods:

 

Method 1 - Get set of files by extension, and move them all

You will need to Get files in folder with a file filter, and then Move files the %Files% variable.

3 times, so 6 actions in total.

 

Method 2 - Get all files, and loop through to move by extension

You will need to Get files in folder without a file filter, and then a For each loop.

In the loop, you can then use If conditional to check if %CurrentItem.Extension% equals .xlsx and so on.

1 loop, 3 conditional blocks, so 11 actions long in total.

 

Method 1 is cleanest, but method 2 is more versatile if there are more parameters of the files to be considered.

View solution in original post

Thanks @Henrik_M !! 

 

I have tested both methods. The first one works. For the second one, it got stuck at the first loop and kept repeating there. 

 

Am new to Power Automate, so have to figure out the basic functions too. 

 

Method 1:

 

image.png

 

Method 2:

 

image.png

 

 

Thanks @DiegoEscobar1 

This is using Flow on the site? I will try it as I go along, after I get more proficient on the Desktop Automate app. Thanks for the tip! 

HI!

Yes, I am using Flow. Sorry I didn't see you wanted to use Power Automate Desktop.

Anyway, if you are looking to do this tasks on cloud files like Ondrive or SharePoint, I recommend to use Flow.

Regards.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,995)