libraguy863 Posted September 7, 2021 Report Share Posted September 7, 2021 PS experts need help copying files from source to dest Src filename_date1.csv filename_date2.csv filename_date3.csv Dest filename_date1.csv Here i want to copy the difference meaning the last 2 files only not the first ..thanks in advance filename_date2.csv filename_date3.csv Quote Link to comment Share on other sites More sharing options...
Pitta Posted September 7, 2021 Report Share Posted September 7, 2021 Quote Link to comment Share on other sites More sharing options...
erragulabi Posted September 7, 2021 Report Share Posted September 7, 2021 check if file exists in destination and move if it doesnt. Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted September 8, 2021 Report Share Posted September 8, 2021 3 hours ago, libraguy863 said: PS experts need help copying files from source to dest Src filename_date1.csv filename_date2.csv filename_date3.csv Dest filename_date1.csv Here i want to copy the difference meaning the last 2 files only not the first ..thanks in advance filename_date2.csv filename_date3.csv I think you can try this… Check the flags..also in case… https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.1 Quote Link to comment Share on other sites More sharing options...
libraguy863 Posted September 8, 2021 Author Report Share Posted September 8, 2021 1 hour ago, dasari4kntr said: I think you can try this… Check the flags..also in case… https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.1 thanks bhai appreciate the links.. the copy process is working as expected i had it working but they is a condition to pick newer files if they get sent like yesterday and todays files are sent today .. both should be picked . based on the date im picking current but as of today i got 2 files it picked todays and not yesterdays that condition i want to know how.. Quote Link to comment Share on other sites More sharing options...
ranam_007 Posted September 8, 2021 Report Share Posted September 8, 2021 should work try this Copy-Item \\server\Sites\xyz.com\App\scripts\xyz.txt \\server\destpath\abc\ -force Copy-Item \\server\Sites\xyz.com\App\scripts\xyz.txt \\server\destpath\abc\ -force Copy-Item \\server\Sites\xyz.com\App\scripts\xyz.txt \\server\destpath\abc\ -force Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted September 8, 2021 Report Share Posted September 8, 2021 30 minutes ago, libraguy863 said: thanks bhai appreciate the links.. the copy process is working as expected i had it working but they is a condition to pick newer files if they get sent like yesterday and todays files are sent today .. both should be picked . based on the date im picking current but as of today i got 2 files it picked todays and not yesterdays that condition i want to know how.. i cant recreate this scenario in my laptop..because i am using mac...just play around it... as per my understanding...you might need to do these steps (if i am correct)... 1. first get the files which created today (or yesterday by tweeking th below...) (Get-ChildItem -File | Where-Object {$_.CreationTime -gt (Get-Date).Date} | Measure-Object).Count 2. do some google about "data piping". which passes the data from one cmdlet to another cmdlet... https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pipelines?view=powershell-7.1 3. in the "Copy-Item" cmdlet...you can use include and exclude... Quote Link to comment Share on other sites More sharing options...
libraguy863 Posted September 13, 2021 Author Report Share Posted September 13, 2021 thanks dasari4kntr n ranam_007 will try both 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.