I am a newbie to scripting so it took me a while to get this to working. I have this vbscript below which finds certain files of a certain filetype. No matter what drive is mapped I can print out a file and its location. I was trying to also get the last modified date and size. I was looking at getfilesize but having problems incorporating this into my script. Any help would be appreciated, thanks.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile Where Extension = 'doc'")
If colFiles.Count = 0 Then
Wscript.Quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\Scripts\PST_Data.txt")
For Each objFile in colFiles
objTextFile.Write(objFile.Drive & objFile.Path & ",")
objTextFile.Write(objFile.FileName & "." & objFile.Extension & ",")
objTextFile.Write(objFile.FileSize & vbCrLf)
Next
objTextFile.Close
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile Where Extension = 'doc'")
If colFiles.Count = 0 Then
Wscript.Quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\Scripts\PST_Data.txt")
For Each objFile in colFiles
objTextFile.Write(objFile.Drive & objFile.Path & ",")
objTextFile.Write(objFile.FileName & "." & objFile.Extension & ",")
objTextFile.Write(objFile.FileSize & vbCrLf)
Next
objTextFile.Close