+ Post New Thread
Results 1 to 2 of 2
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 ...
  1. #1

    Join Date
    Nov 2011
    Posts
    608
    Thank Post
    84
    Thanked 21 Times in 19 Posts
    Rep Power
    10

    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

  2. #2

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    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:
+ Post New Thread

Similar Threads

  1. Best program to create time lapse movie from an AVI file?
    By tech_guy in forum How do you do....it?
    Replies: 0
    Last Post: 10th May 2010, 11:26 AM
  2. File/Folder deleting and moving
    By Stumpy in forum How do you do....it?
    Replies: 3
    Last Post: 7th July 2008, 05:19 PM
  3. USB Flash file restore program
    By timbo343 in forum Windows
    Replies: 7
    Last Post: 20th February 2007, 12:29 PM
  4. Mass search and replace
    By Fletcher_Bravo in forum Windows
    Replies: 2
    Last Post: 5th July 2006, 03:44 PM
  5. Locate and edit text files
    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
  •