Powershell: Kasutamata failide liigutamine: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Created page with '<# 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: …' |
mNo edit summary |
||
Line 1: | Line 1: | ||
<Source lang="powershell"> | |||
<# | <# | ||
Title: Moving unused files | Title: Moving unused files | ||
Line 25: | Line 26: | ||
} | } | ||
} | } | ||
</source> |
Latest revision as of 16:24, 20 November 2012
<#
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
}
}