Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell Move Files based on Date

$
0
0

I need a powershell script to move files from one target location to another target location based on the date I specified. The script also needs to override any existing files in the destination location if they exist.

This is what I had so far but its based on how many days from today:

Powershell
$path="C:\temp\others\"$destination=new-itemc:\temp\others\$($date.toshortdatestring().replace("/","-"))-typedirectoryForeach($filein(Get-ChildItem$path)){If($file.LastWriteTime-gt(Get-Date).adddays(-1).date){Move-Item-Path$file.fullname-Destination$destination}}

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>