Solved

Delete files from share on files server.

Posted on 2011-02-24
3
356 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
Comment Utility
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
Comment Utility
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
Comment Utility
... 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

Why do Marketing keep bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

Join & Write a Comment

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
If you migrate a Terminal Server licenses server inside the 2008 server family, you can takte advantage of the build-in migration tool. If you like to migrate an older 2003 Server (and the installed client CALs) to a 2008 R2 server for example, you …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now