web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Suggested Answer

Move files

(0) ShareShare
ReportReport
Posted on by 14

Hello i would like to use move files. But i cant figure out how to do something like this

 

For each folder

Loop

Lets say our main folder is admin

admin has 5 subfolder more or less

each folder has 2 subfolders and inside those are the files that i want to move next to that 2 subfolder. and delete the rest.

 

The problem i am having the 5 subfolder always have different names (but they end the same if it helps) how do i gram the files from subfolders and move it up

 

ps. i cant move all bc it would also put the other unworked files up and it would be a mess.

  • CU11031527-0 Profile Picture
    4 on at
    Hi,
     
    I have a similar issue, were you able to get a solution to copy the files?
     
    Thanks!
  • Suggested answer
    eetuRobo Profile Picture
    4,587 Super User 2026 Season 2 on at
    Hello

    Try something like this:



    So first use Get subfolders in folder to the "admin" folder (the parent folder). Do not include subfolders.


    Then use For each loop to go through those folders in the admin folder. In that first loop get subfolders again so that you can go through the files of those folders one by one and move the files to the currentAdminFolder.

    In the start I had admin folder which has 5 subfolders. 


    All those subfolders have 2 subfolders inside them



    And those subfolders have some files in them




    After the flow has run it looks like this:


    The sub-subfolders (most bottom folders) are empty since the files are moved to one folder up admin subfolders



    Code to paste to your flow editor:
    Folder.GetSubfolders Folder: $'''C:\\Users\\YourUser\\Desktop\\admin''' FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> AdminFolders
    LOOP FOREACH CurrentAdminFolder IN AdminFolders
        Folder.GetSubfolders Folder: CurrentAdminFolder FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> SubFolders
        LOOP FOREACH CurrentItem IN SubFolders
            Folder.GetFiles Folder: CurrentItem FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
            File.Move Files: Files Destination: CurrentAdminFolder IfFileExists: File.IfExists.DoNothing MovedFiles=> MovedFiles
        END
    END
    
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 245 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#3
Valantis Profile Picture

Valantis 136 Super User 2026 Season 2

Last 30 days Overall leaderboard