Solved

How do I make a script to delete files I specify, from hundreds of different directories? (Or a program that will do it for me)

Posted on 2008-06-12
10
213 Views
Last Modified: 2010-04-16
Hi Experts

I'm a systems administrator at a school with over 1000 student accounts. We've had quite a number of kids bringing games and unwanted material into the school, and storing it on their home drives.

What I would like to do is have a utility that scans all these folders at night time looking for files I specify, and delete them. A Batch file or something. I have a large list of files that I know I wan't removed without question (like quake system files, flash games etc) I just need to give them to a program to deal with them.

Can anyone help, or suggest some software that will do this for me?

Kind of like a Virus scanner, but one that allows me to specify what it scans for.

Thanks

Jono
0
Comment
Question by:jonathanpace
10 Comments
 
LVL 9

Expert Comment

by:authen-tech
ID: 21776014
You might want to look into something like the Shared Computer Toolkit (now known as SteadyState)
http://www.microsoft.com/downloads/details.aspx?FamilyId=D077A52D-93E9-4B02-BD95-9D770CCDB431&displaylang=en

It will let you lock down the computers after you get them cleaned up and not allow for the installation of such files.  
0
 

Author Comment

by:jonathanpace
ID: 21776084
Thats not what I am after. The computers are locked down tight.

The students are copying things from USB memory keys onto their home drives. Movies, games that don't need to be installed, etc.

I want something server side where the home folders are stored to hunt down and destroy these kinds of things at night time.
0
 

Author Comment

by:jonathanpace
ID: 21776132
oh, whatever I use needs to be able to search for things I specify, because we can't just go and delete "*.wmv" and things like that because there are student assignments that are stored in the format etc.

Are there any programs out there?
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 7

Expert Comment

by:ManicD
ID: 21777526
You could try a software restriction policy. it wouldnt remove the files but it would stop them being accessable to students. Then afater a while once the theory that they can be used has spread a simple windows search and delete should remove the rubbish.


More information.
http://support.microsoft.com/kb/324036
http://technet.microsoft.com/en-us/library/bb457006.aspx
0
 

Author Comment

by:jonathanpace
ID: 21777688
I don't need any restriction policies as everything is locked down via group policy.

And installing software on individual PC's is out of the question, as there is over 1000 of them..

I need something server side, that will search for files that I specify in a bulk list. That way I can run it every night to remove any software automatically that I have specified in this list.

Will be easy because we have one server storing all the home folders, so it would just trawl through these folders deleting the stuff specified.

I was going to write a batch file and use "/s" commands, but if I specified 100 different files, then it would have to trawl through over 1000+ folders one at a time searching 100 times, and that would take too long and kill the disks from excessive flogging every night.


I'm running out of ideas..
0
 
LVL 22

Accepted Solution

by:
Paka earned 125 total points
ID: 21782467
Since you're only looking for file names, the batch delete method should only scan the MFT (not the entire disk) and won't flog your drives too badly.

You might be able to create virus signatures for the "bad" software and add it to the virus signatures.  I know that the Symantec SMTP anti-virus lets you define bad software names and it will quarratine/delete these files.
0
 

Assisted Solution

by:WendyDun
WendyDun earned 125 total points
ID: 21810222
Use Powershell and have a script something like the following.

You can modify it to work on whole directories as well - simply pass a high level directory name in as the filter and add the "-recurse" option to the Remove-Item line.
Function delFiles ($TargetFolder, $filter)
{
    $files = get-childitem $TargetFolder -recurse -filter $filter
    if ($files -eq $null) {return} #oddly, if nothing is returned, the foreach will do one iteration
    foreach ($f in $files)
    {
        write-host "Deleting File $f" -foregroundcolor "Red"
        Remove-Item $f.FullName -force # force ensures that readonly files are deleted. 
    }
}
 
# the filter will accept wildcards or exact matches
delFiles "c:\" "*.bad" 
delFiles "c:\" "FileNamed.xxx"

Open in new window

0
 

Author Comment

by:jonathanpace
ID: 21851017
I will try this and get back to you. Thanks for your help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

820 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