Move older files with PowerShell
Move older files with PowerShell
set the source path
set the destination path
set the days 30days old = -30
set exclude files
set exclude files
save it as move.ps1
===========================================
$YourPath = "source"
$YourDest = "destination"
$daysback = "-30”
Get-ChildItem -Path $YourPath -Exclude abc.txt, abc.png, abc.jpg, xyz_voucher_bottom.jpg, bbc.jpg | where {$_.LastWriteTime -lt ((Get-Date).AddDays($daysback ))} |
move-item -Destination $YourDest
Comments
Post a Comment