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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Move files to a folder...
Power Automate
Answered

Move files to a folder based on last modified date

(0) ShareShare
ReportReport
Posted on by 10

I want to move files that are older than a day to a different folder based on their last modified date.

For example, move File1 that was last modified on Jan 14, 2021 to ...reports\2021\01\14. Repeat this for every file in ...reports\ (not including sub folders). The path structure is simply yyyy\mm\dd (if this subfolder does not exist, create it).

 

How can I go about that?

Categories:
I have the same question (0)
  • Verified answer
    manuelstgomes Profile Picture
    6,625 on at

    Hi @igonzalez1 

     

    I'm going to assume that the files are in your OneDrive, but the process is the same if they are in SharePoint.

     

    For the condition to take one day

    addDays(utcNow(),-1)

     

    To get the day, month, and year:

    formatDateTime(items('Apply_to_each')?['LastModified'],'dd')
    formatDateTime(items('Apply_to_each')?['LastModified'],'MM')
    formatDateTime(items('Apply_to_each')?['LastModified'],'yyyy')

     

    And here's the full Flow:

    Screenshot_2021-02-09_at_18_56_55.jpg

     

    Can you please check if and let me know if you have any questions?

     

    Cheers
    Manuel

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • igonzalez1 Profile Picture
    10 on at

    Hi @manuelstgomes 

    Thank you very much. Yes, it's OneDrive for Business. Couple of questions:

    1. Does 'List files in folder' include subfolders? If so, how to disable it? If it doesn't, how can I make it include subfolders? I don't see an option.
    2. Is 'List files in folder' updated after every loop of 'Apply to each'? I hope not.
  • manuelstgomes Profile Picture
    6,625 on at

    Hi @igonzalez1 

     

    The "List files in the folder" list the whole contents of a folder (folders and files) and return a flag (isFolder) so that you know if an entry is a file or a folder. It won't drill down if you want to do that; you need to do a more complex Flow where if it finds a folder, it will call another Flow (or the same one) to find information under that directory recursively. I can show you how, but it's a little bit more tricky. 

     

    Regarding your second question, no. The Flow fetches all the information in the "List files in folder" step and uses it until the flow. Each action is always like a snapshot. It collects the data as it is at the moment.

     

    Cheers
    Manuel

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard