Windows 7 Thread, Search and move old files. Best program in Technical; Hi,
We are looking to go through our shared drives and remove anything that hasnt been accessed in a few ...
-
8th February 2012, 01:22 PM #1
- Rep Power
- 0
Search and move old files. Best program
Hi,
We are looking to go through our shared drives and remove anything that hasnt been accessed in a few years.
We would like to be able to search for files that havnt been accessed and then move them to our archive area. We would however like to keep the file in the same directory. e.g. if a file came out of english\ks4 it moves archive\english\ks4.
Is there a bit of software to do this?
Many thanks,
Dan
-
-
IDG Tech News
-
8th February 2012, 02:58 PM #2 You can do it pretty easily with any scripting language, heres an example in powershell. I didn't test it that much :P
Code:
function New-ArchiveFolder()
{
param($SourceFolder, $DestFolder)
$folder = New-Object PSObject
$folder | Add-Member -Type NoteProperty -Name Source -Value $SourceFolder
$folder | Add-Member -Type NoteProperty -Name Destination -Value $destFolder
return $folder
}
# Array of archive folders to process for archving
$archiveFolders = @(
(New-ArchiveFolder -SourceFolder "C:\Intel" -DestFolder "C:\Archive\Intel")
)
# Minimum age in days of files to be archived
$minArchiveAge = 30
foreach ($archiveFolder in $archiveFolders)
{
if (!(Test-Path $archiveFolder.Source)) { continue }
$sourceFolderUri = New-Object System.Uri("$($archiveFolder.Source)\")
$files = (Get-ChildItem -Path $archiveFolder.Source -Recurse | where { !$_.PsIsContainer -and (((Get-Date) - $_.LastAccessTime).Days -ge $minArchiveAge) })
if (!$files) { continue }
foreach ($file in $files)
{
$fileName = $file.Name
$filePath = $file.DirectoryName
$filePathUri = New-Object System.Uri("$filePath\")
$archivePathUri = $sourceFolderUri.MakeRelativeUri($filePathUri)
$archivePath = "$($archiveFolder.Destination)\$($archivePathUri.ToString())"
if (!(Test-Path $archivePath))
{
New-Item $archivePath -Type Directory
}
$file.MoveTo("$archivePath\$fileName")
}
}
-
SHARE:
Similar Threads
-
By tech_guy in forum How do you do....it?
Replies: 0
Last Post: 10th May 2010, 11:26 AM
-
By Stumpy in forum How do you do....it?
Replies: 3
Last Post: 7th July 2008, 05:19 PM
-
By timbo343 in forum Windows
Replies: 7
Last Post: 20th February 2007, 01:29 PM
-
By Fletcher_Bravo in forum Windows
Replies: 2
Last Post: 5th July 2006, 03:44 PM
-
By _Bob_ in forum Scripts
Replies: 14
Last Post: 7th June 2006, 02:11 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules