Oracle 74 Posted August 24, 2022 Share Posted August 24, 2022 Hi, all. I'm continuing the build out a script that will backup data from my Synology NAS to a few different External HDDs. I have my script currently using RoboCopy, but want to extend my knowledge on PowerShell and attempt to use Copy-Item to achieve what I am looking for. Ideally, the script would recursively scan through my tree, and if the file is there, skips the copy of that file. Anything new, is copied. Trying this out before, I am able to achieve the copy, but it copies everything over, regardless of whether it is present on the server. Any thoughts or advice? Link to comment Share on other sites More sharing options...
justinrh 174 Posted August 25, 2022 Share Posted August 25, 2022 Probably need to use get-childitem to get a list of all movies in both repositories, then compare one to the other, but that could take a lot of CPU cycles if you have a lot of files, I'd think. Use -filter *.mp4 to find your files (it is faster). You might want to experiment with compare-object with your two files lists and see if you can pull out the diff that way instead of looping #-files times thru comparing to your baseline list. Oh, oh, use -contains (or the .NET method .contains) to search the baseline array. That should be sufficient. $arrayBaseline $arrayNewstuff $arrayNewstuff | where-object {$arrayBaseline -notcontains $_} will return an array of just new files So many possibilities - which makes it fun and frustrating. Then you can include .NET or not, which makes it fun, too. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now