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
208 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 …

708 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

16 Experts available now in Live!

Get 1:1 Help Now