Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WSH Script to remove media files from user shares?

Status
Not open for further replies.
Aug 18, 2002
44
US
I've been trying to create a logon script to traverse all the directories in a user's network share to locate and move media files (MP3s, MPEGs, etc.) to a user's local drive, however, I do not understand it enough to make it work.

Are there any WSH geniuses out there who can help me out?

The main reason we'd like to implement this is because we will be using folder redirection for desktop and My Docs. And inevitably, user's will be saving such no-no's as MP3s to these directories. A script such as this would help to remove them on a daily basis.

Some might say that you should just make it a policy that none of these types of files can be stored on company servers, but I'd still need a way to traverse the folders and shares to find them and delete them. Such a script would be helpful and can be easily modified to delete or log the files.

Thanks in Advance!
 
Well a simple batch file can do this for you.
Something along the lines of:

To just echo the found files:
Code:
@echo off
for /F %%f in (extenstions.txt) do (for /R %%i in (*.*) DO IF %%~xi == %%f echo %%i)

To delete the found files:
Code:
@echo off
for /F %%f in (extenstions.txt) do (for /R %%i in (*.*) DO IF %%~xi == %%f echo y | del %%i)
All you would need to to is make a text file with the bad extentions listed ie:
.mp3
.wmf

It will delete the file without asking for confirmation.

You can change the add to the *.* to start in a certain directory if you like.

Its also recursive so it will search the whole tree from its starting location.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top