|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
AND Drive='D:' AND Path='\\folder1\\subfolder2\\test\\'
"Walid" wrote: > Hi, > I am pretty new to scripting. I found this script from "scripting guy" and > I want to know how I can echo or even delete files within a specific folder > (for example D:\folder1\subfolder2\test) for files older than Jan 2nd 2007. > I thought it would work if I change the line " AND Drive = > 'D:\folder1\subfolder2\test'"). But this doesn't work. I would appreciate > any ! > > Thanks, > > WG > > strDate = "20070102000000.000000+000" > > strComputer = "." > Set objWMIService = GetObject _ > ("winmgmts:\\" & strComputer & "\root\cimv2") > Set colFiles = objWMIService.ExecQuery _ > ("Select * From CIM_DataFile Where CreationDate < '" & strDate & "'" & _ > " AND Drive = 'D:'") > For Each objFile in colFiles > Wscript.Echo objFile.Name > Next > > |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
That worked; thank-you very much!!
How would I modify this script if I want to echo based on "modified" date, file size, file type (.doc, .pdf, .... etc)? Thanks for the assistance! WG "JFord" wrote: > AND Drive='D:' AND Path='\\folder1\\subfolder2\\test\\' > > "Walid" wrote: > > > Hi, > > I am pretty new to scripting. I found this script from "scripting guy" and > > I want to know how I can echo or even delete files within a specific folder > > (for example D:\folder1\subfolder2\test) for files older than Jan 2nd 2007. > > I thought it would work if I change the line " AND Drive = > > 'D:\folder1\subfolder2\test'"). But this doesn't work. I would appreciate > > any ! > > > > Thanks, > > > > WG > > > > strDate = "20070102000000.000000+000" > > > > strComputer = "." > > Set objWMIService = GetObject _ > > ("winmgmts:\\" & strComputer & "\root\cimv2") > > Set colFiles = objWMIService.ExecQuery _ > > ("Select * From CIM_DataFile Where CreationDate < '" & strDate & "'" & _ > > " AND Drive = 'D:'") > > For Each objFile in colFiles > > Wscript.Echo objFile.Name > > Next > > > > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Here is a free tool called ScriptoMatic it will you with your WMI queries
http://www.microsoft.com/downloads/d...displaylang=en There are a lot of properties you can query off of - LastModified - FileType - Extension - FileSize You will see these in the ScriptoMatic tool, or just google the WMI Class name http://msdn2.microsoft.com/en-us/library/aa387236.aspx Also as 'tonyr' suggests sometimes vbscript can create a mental block, powershell is pretty good and there are a few examples out there for it as well. "Walid" wrote: > That worked; thank-you very much!! > How would I modify this script if I want to echo based on "modified" date, > file size, file type (.doc, .pdf, .... etc)? > > Thanks for the assistance! > > WG > > "JFord" wrote: > > > AND Drive='D:' AND Path='\\folder1\\subfolder2\\test\\' > > > > "Walid" wrote: > > > > > Hi, > > > I am pretty new to scripting. I found this script from "scripting guy" and > > > I want to know how I can echo or even delete files within a specific folder > > > (for example D:\folder1\subfolder2\test) for files older than Jan 2nd 2007. > > > I thought it would work if I change the line " AND Drive = > > > 'D:\folder1\subfolder2\test'"). But this doesn't work. I would appreciate > > > any ! > > > > > > Thanks, > > > > > > WG > > > > > > strDate = "20070102000000.000000+000" > > > > > > strComputer = "." > > > Set objWMIService = GetObject _ > > > ("winmgmts:\\" & strComputer & "\root\cimv2") > > > Set colFiles = objWMIService.ExecQuery _ > > > ("Select * From CIM_DataFile Where CreationDate < '" & strDate & "'" & _ > > > " AND Drive = 'D:'") > > > For Each objFile in colFiles > > > Wscript.Echo objFile.Name > > > Next > > > > > > |
|
![]() |
| Outils de la discussion | |
|
|