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 Platform Community / Forums / Power Automate / Move folder based on f...
Power Automate
Answered

Move folder based on files inside.

(0) ShareShare
ReportReport
Posted on by 4

I am using get files in folder and get subfolders in folder including generating the flow variables.

I have created a input variable called AAFile using a file name that would be AA000*.zip.  This file name always exists.

But missing the logic of looping and determining if that file is in that folder. So if the file exists do this else that.

For visual example let's say I have 6 folders:

AFolder (should be moved)
     -File1.jpg
     -File2-1of3.zip
     -File2-2of3.zip
     -File2-3of3.zip

BFolder (should be moved)
     -File1.jpg
     -File2-1of3.zip
     -File2-2of3.zip

CFolder (should be deleted after moving file)
     -File1.jpg
     -AA000File22341.zip (file needs moving)

DFolder (should be deleted after moving file)
     -File1.jpg
     -AA000File2211251.zip (file needs moving)

EFolder (should be moved)
     -File1.jpg
     -File2-1of3.zip
     -File2-2of3.zip
     -File2-3of3.zip
FFolder (should be moved)
     -File1.jpg
     -File2-1of3.zip
     -File2-2of3.zip

Inside those would be a JPG and atleast 1 ZIP file. Can someone tell me how to sort through and determine if the file %AAFile%
is there. Then if it is not, move the folder to another location. If the file is there, move only the file to a different location and then delete that folder.

If I use a For Each loop it seems like PAD doesn't like me to use If file exists action to Move a folder.

Thanks everyone

I have the same question (0)
  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    Get files from folder (include sub folders) for AA000*

    for each %CurrentItem% in %Files%

        move %CurrentItem% to [move location for AA files]

        Delete folder %CurrentItem.Directory%
    end (for each)

     

    get folders (sub folders on main folder)

    for each %CurrentItem% in %Folders%
        Move folders to [move folder location]

    end(for each)


    so. Two pieces, first, we find all AA files, we move the AA files, and delete their folder.

     

    then we find the remaining folders and move them. 

    best of luck!
        

  • Diophantus Profile Picture
    4 on at

    Works exactly as it should!  Thank you so much.

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 233

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 190

Last 30 days Overall leaderboard