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 / Help to copy only new ...
Power Automate
Unanswered

Help to copy only new files

(0) ShareShare
ReportReport
Posted on by 31

I am just getting started with flows but haven't found an answer to this. my flow gets a list of all png files in a directory then transfers them to a onedrive folder. I want it to run every night BUT only transfer items that are not currently in the onedrive folder. 

 

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Do you have the freedom to move those files locally (say to a subfolder called "filed") after they have been filed in OneDrive?

  • davidcab Profile Picture
    31 on at

    The query of files is all png files from a large share on my server with many subfolders. 

    I am copied all files to a personal onedrive for now, might change to sharepoint later, but i want to run this nightly and only pull new files added to the share. 

     

    I prefer not to add any new folders on the server share. I can do anything to my onedrive. 

  • Henrik_M Profile Picture
    2,021 Super User 2024 Season 1 on at

    You can tell the action to do nothing if a file exists, which is also the default.

    Maybe I'm misunderstanding the challenge...? 🤔

    Henrik_M_1-1664911254209.png

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Henrik has a point, but if it's 1000s of files, you don't want it to have to reject every single one that is not new.  So, here you go:

     

    Get files *.png for [ FromAddress and all Subfolders] to %Files% sort by Last Modified descending (newest on top).

    Get files *.png for [ToAddress and all Subfolders] to %MyFiles% sort by Last Modified descending (newest on top).

     

    Loop Condition While %Files[LoopIndex].Modified% >= %MyFiles[0].Modified% from LoopIndex of 0 to %Files.Count - 1%

        Move %Files[LoopIndex]% to %ToAddress%

    End Loop

     

    In English, this says as long "Last Modified Date/Time" of the file is later than (or equal to) the "Last Modified Date/Time" of my most recent file, move it, and as soon as it is not, end the loop.  This will stop it from having to do logic on all the files because it will exit the loop as soon as it is done with the "new" files.

     

  • davidcab Profile Picture
    31 on at

    This can work but ideally i'd like to prevent it from checking all 5000+ files each time. and only check new ones.

    I guess i can leave it as is for now. a full run takes under 2 minutes. 

  • davidcab Profile Picture
    31 on at

    This can work but ideally i'd like to prevent it from checking all 5000+ files each time. and only check new ones.

    I guess i can leave it as is for now. a full run takes under 2 minutes. 

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

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 178

Last 30 days Overall leaderboard