Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delete files from share on files server.

Posted on 2011-02-24
3
Medium Priority
?
372 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 2000 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 2000 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

671 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