Thanks Jeffery, but that is the problem. I am not versed enought in functions
to make it delete the sub-folders and or files.
"Jeffery Hicks [MVP]" wrote:
> See if this s get you in the right direction.
>
> On Error Resume NextstrFolder="f:\data"
> Set objFSO=CreateObject("Scripting.FileSystemObject")
> Set objFolder=objFSO.GetFolder(strFolder)
> Set colFiles=objFolder.Files
> For Each file In colFiles
> If Int(DateDiff("d",file.DateLastModified,Now)) >= 60 Then
> WScript.Echo "Deleting " & file & " (" &_
> file.DateLastModified & ")"
> objFSO.DeleteFile file,True
> If Err.Number<>0 Then
> WScript.Echo "**Failed to delete " & file & ". Error# " &_
> Err.Number & " " & Err.Description & "**"
> End If
> End If
> Next
> 'end of script
>
> This script finds all files in F:\Data that are > 60 days old based on date
> last modified and deletes them. You could take this code and create a
> function so you could recurse through subfolders.
>
> --
> Jeffery Hicks
> Microsoft PowerShell MVP
> http://www.scriptinganswers.com
> http://www.powershellcommunity.org
>
> Now Available: WSH and VBScript Core: TFM
> Coming Soon: Windows PowerShell: TFM 2nd Ed.
>
> "po_boy" <poboy@discussions.microsoft.com> wrote in message
> news
DFA0136-97B9-4D00-B847-0614060EF44F@microsoft.com...
> >I have some files and folders under C:\LogFiles. This folder has many
> > subfolders and files. I need to find an easy way to delete the files or
> > folders(subfolder) that are older than X days. Most scripts only do a
> > folder
> > and files but not a group and since I am not that good with scripts it is
> > not
> > working well for my needs. Please assist.
>