Solved

Delete files from share on files server.

Posted on 2011-02-24
3
366 Views
Last Modified: 2012-05-11
We have a scanner that places Documents in the folder on one of the shares on our file server.  Of course people scan stuff in and then just leave it there.  Is there someway to automatically delete the files in the shares after a week?

Our file server is Windows server 2008.  We are running Active Directory from another 2008 server.
0
Comment
Question by:dayspringit
  • 2
3 Comments
 
LVL 3

Expert Comment

by:Speedfox6
ID: 34971486
As far as I know there is no windows program to do this, however there is a free software called Cyber-D's Autodelete which can be found here. I use it on my server for a similar use.

http://cyber-d.blogspot.com/2005/10/cyber-ds-auto-delete-101.html

Good luck!
0
 
LVL 5

Accepted Solution

by:
NotVeryFat earned 500 total points
ID: 34971527
Save the following as a VB file (eg delfiles.vbs), then create a batch file with the following line: delfiles.vbs c:\ShareYouWantToDeleteFrom 7

(7 is the number of days)


Set objArgs = WScript.Arguments
FolderName =objArgs(0)
Days=objArgs(1)

set fso = createobject("scripting.filesystemobject")
set folders = fso.getfolder(FolderName)
datetoday = now()
newdate = dateadd("d", Days*-1, datetoday)
wscript.echo "Today:" & now()
wscript.echo "Started deleting files older than :" & newdate
wscript.echo "________________________________________________"
wscript.echo ""
recurse folders
wscript.echo ""
wscript.echo "Completed deleting files older than :" & newdate
wscript.echo "________________________________________________"

sub recurse( byref folders)
  set subfolders = folders.subfolders
  set files = folders.files
  wscript.echo ""
  wscript.echo "Deleting Files in:" & folders.path
  wscript.echo "__________________________________________________________________________"
  for each file in files
    if file.datelastmodified < newdate then
      wscript.echo "Deleting " & folders.path & "\" & file.name & " last modified: " & file.datelastmodified
      on error resume next
    file.delete
    end if
   
  next  

  for each folder in subfolders
    recurse folder
  next  

  set subfolders = nothing
  set files = nothing

end sub
0
 
LVL 5

Assisted Solution

by:NotVeryFat
NotVeryFat earned 500 total points
ID: 34971540
... And then schedule the .bat file using Windows Scheduler.

I got this script online years ago and has worked very well ever since (sorry, I don't know where I got it to give credit!)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question