Solved

Delete files from share on files server.

Posted on 2011-02-24
3
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

751 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