Powershell: Kasutamata failide liigutamine

From ICO wiki
Jump to navigationJump to search
<#
Title:        Moving unused files
Description:  Moves files from desktop that haven't been accessed for a week.  
Author:     Carolys Kallas
Version:     2.0
Date Created:    12.11.12
Date Modified:    13.11.12
http://www.isurinder.com/blog/post/2012/04/26/My-First-PowerShell-Script-Moving-Files-From-One-Directory-to-Another.aspx
http://serverfault.com/questions/153995/how-can-i-identify-unused-files-on-a-windows-share
#>
$Cutoffdate = (Get-date).AddDays(-7) 

#Destination for files
$DropDirectory = "C:\Drop\"

#Location of files 
$PickupDirectory = Get-ChildItem "C:\Users\Carolys\Desktop\"

foreach ($file in $PickupDirectory)
{
    if ($_.LastAccessTime lt $Cutoffdate)
    {
    $Destination = $DropDirectory+$file.Name
    Move-Item $file.FullName -destination $Destination
    }
}