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
$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