Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
but i get an error when i try to delete files
ps. the recycle bin is for Pussies
Quotebut i get an error when i try to delete filesWhat error might that be? We're not psychic (at least not all of us)You can try the delete method without the parens: fso.Deletefile objFile OR fso.Deletefile objFile, TrueThe true option will force read-only files to be deleted. Quoteps. the recycle bin is for Pussies Can I quote you the next time some poster appears on the CH doorstep looking for their lost files? Always
Set fso = CreateObject("Scripting.FileSystemObject")fs = "c:\temp\temp" 'point to your directoryShowFiles(fs)Sub ShowFiles(Fld) Set k = fso.GetFolder(Fld) Set s = k.SubFolders Set kf = k.Files For Each objFile In kf If fso.GetExtensionName(objFile) = "avi" then If objFile.DateCreated < date - 5 Then WScript.Echo objFile & " " & objFile.DateCreated fso.DeleteFile objfile End If End if Next For Each SubFolder In s ShowFiles SubFolder NextEnd Sub
and now i can only select 1 extension by default it's avi. *.* works fine for me Wink < Yes i fixed this
I hate how there isnt a option to just delete the everything in recyle bin every few days.Or turn it off.
i am a PHP coder so i know the basics for programming
Set fso = CreateObject("Scripting.FileSystemObject")fs = "c:\temp\temp" 'point to your directoryShowFiles(fs)Sub ShowFiles(Fld) Set k = fso.GetFolder(Fld) Set s = k.SubFolders Set kf = k.Files For Each objFile In kf If objFile.DateCreated < date - 5 Then WScript.Echo objFile & " " & objFile.DateCreated fso.DeleteFile objfile End If Next For Each SubFolder In s ShowFiles SubFolder NextEnd Sub
Set fso = CreateObject("Scripting.FileSystemObject")fs = "c:\dvr_data" ShowFiles(fs)Sub ShowFiles(Fld) Set k = fso.GetFolder(Fld) Set s = k.SubFolders Set kf = k.Files For Each objFile In kf 'If fso.GetExtensionName(objFile) = "avi" then 'If objFile.DateCreated < date - 3 Then WScript.Echo objFile & " " & objFile.DateCreated 'fso.DeleteFile objfile 'End If 'End if Next For Each SubFolder In s ShowFiles SubFolder NextEnd Sub
Set fso = CreateObject("Scripting.FileSystemObject")fs = "c:\dvr_data" ShowFiles(fs)Sub ShowFiles(Fld) Set k = fso.GetFolder(Fld) Set s = k.SubFolders Set kf = k.Files For Each objFile In kf If fso.GetExtensionName(objFile) = "avi" then 'If objFile.DateCreated < date - 3 Then WScript.Echo objFile & " " & objFile.DateCreated 'fso.DeleteFile objfile 'End If End if Next For Each SubFolder In s ShowFiles SubFolder NextEnd Sub
Set fso = CreateObject("Scripting.FileSystemObject")fs = "c:\dvr_data" ShowFiles(fs)Sub ShowFiles(Fld) Set k = fso.GetFolder(Fld) Set s = k.SubFolders Set kf = k.Files For Each objFile In kf If fso.GetExtensionName(objFile) = "avi" then If objFile.DateCreated < date - 3 Then WScript.Echo objFile & " " & objFile.DateCreated 'fso.DeleteFile objfile End If End if Next For Each SubFolder In s ShowFiles SubFolder NextEnd Sub
fs = "c:\dvr_data"
This script worked great even using a UNC path, I was just wondering if anyone could tell me how to set it to check multiple locations? Like maybe point to a file with a list of locations vs. just the one location at the top?Code: [Select]fs = "c:\dvr_data"