lsheldon Posted February 27, 2009 Posted February 27, 2009 Now its .SWF I now need to delete .swf also, but wait its not that simple I need to delete .swf over a certain size as the smaller .swf files are students work and the larger ones are games. I want to add this to the current script if possible any ideas ? compact /u /s /f attrib * -s -H -R -A /S del *.zip /s /f del *.exe /s /f del *.tmp /s /f del Thumbs.db /s /f this script run's on the student file server every night and tidys the areas as it scans all sub files and folders also.
ChrisH Posted February 27, 2009 Posted February 27, 2009 (edited) A VB script would be best for this. It will do a WMI query for file type and file size > X . Then you can do what you want with it. If you need the flesh of it theres one of my scripts that changed file formats. You can alter that for your purposes: http://www.edugeek.net/forums/windows/5400-batch-image-convert.html 'WMI Script to find certain file types and run a command on them 'Chris Hindmarch FisherMore R.C High 'I take no responsibility if this script messes anything up ' Use with extreme caution as it will act on **ALL** the files of the ' defined file type in the path strComputer = "." Path = "E:\Home\FMStudent" 'Path to the root of the directory to search recursively OutPath = "" OutputFormat = "jpg" Drive ="" FilePath= "" FileSize = 0 StrCmdLine = "" Ext = "bmp" ' Set the filetype you are looking for ommit the "." Set ObjShell = CreateObject("WScript.Shell") ' Replace back slashes with double back slashes else an error will occur Path = Replace(Path,"\","\\") FilePath = LCase(Path)'Convert to lower case as wmi ouputs in lower case 'Get drive letter Drive = Left(FilePath,2) WScript.echo "Drive= " & Drive 'Get the rest of the path FilePath=Right(FilePath,(Len(FilePath) -2)) 'Create the like query string FilePath = "%" & FilePath & "%" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFiles = objWMIService.ExecQuery _ ("Select Drive,Path,Extension,FileSize,FileName from CIM_DataFile where Extension = '" & ext &_ "' and Drive = '" & Drive & "' and Path Like '" & FilePath & "'") WScript.echo "The Parent File Path = " & FilePath 'Wscript.echo "The amount of files found was " & colfiles.count If ColFiles.Count >= 1 Then For Each objFile In colFiles 'Get the full file path CombinedPath = objFile.drive & objFile.Path & objFile.FileName & "." & objFile.Extension WScript.Echo "THe Combined Path = " & CombinedPath 'Alter File path to reflect new file type OutPath = Replace(CombinedPath,Ext,OutputFormat) 'WScript.echo objFile.drive & objFile.Path & objFile.FileName & "." & objFile.Extension FileSize = FileSize + objFile.FileSize StrCMDLine = "c:\imagemagick\convert.exe " & """" & CombinedPath & """" & " " & """" & OutPath & """" WScript.Echo StrCMDLine ObjShell.Run StrCmdLine,1,True 'End IF Next Else WScript.echo "No Files Found or incorrect path specified" End If 'IF ColFiles.Count >= 1 Then FileSize = FileSize/1024 WScript.echo "Disk Space in KiloBytes= " & FileSize & VbCrLf FileSize = FileSize/1024 WScript.echo "Disk Space in Meg= " & FileSize & VbCrLf FileSize = FileSize/1024 WScript.echo "Disk Space in Gigs= " & FileSize & VbCrLf Edited February 27, 2009 by ChrisH 1
lsheldon Posted February 27, 2009 Author Posted February 27, 2009 This would be great but my experience in vbs is still limited so i would nob be sure how to manipulate the script for my needs
mattx Posted February 27, 2009 Posted February 27, 2009 Use Agent Ransack to search with the size limits - [ part of the Admin Bar see below ] or DL it from Agent Ransack - home Once finished searching you can then simply highlight the files and delete.....
lsheldon Posted February 27, 2009 Author Posted February 27, 2009 I need to do this automatically though
mattx Posted February 27, 2009 Posted February 27, 2009 I would knock something up in AutoIT then using the FileGetSize function...... Function FileGetSize
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now