sjumu
asked on
Script to List 0kb files
Hi,
I have a windows 2003 file system which after a crash and chkdsk has resulted in some existing files having a 0kb size. I need a to create a list of filenames and paths for these files for potential recovery.
Does anyone have a script out there that does this?
Thx
Sjumu
I have a windows 2003 file system which after a crash and chkdsk has resulted in some existing files having a 0kb size. I need a to create a list of filenames and paths for these files for potential recovery.
Does anyone have a script out there that does this?
Thx
Sjumu
ASKER
Hi alphaphaedrus,
Thanks for the quick reply, I put the script into a .wsf files and tried to run it
but I get errors about "Unterminated entity reference - matching ';' not found"
Am I doin something wrong here?
sjumu
Thanks for the quick reply, I put the script into a .wsf files and tried to run it
but I get errors about "Unterminated entity reference - matching ';' not found"
Am I doin something wrong here?
sjumu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Footech,
This is great!! exactly what I needed after I installed Powershell on the 2k3 server I could do so much more. I was able to pipe you code further to give me the full liast of paths for each file and write to a log
Get-ChildItem -path c:\ -force -recurse | where {$_.length -eq 0} |Select-Object -Property FullName
Many Thanks
sjumu
This is great!! exactly what I needed after I installed Powershell on the 2k3 server I could do so much more. I was able to pipe you code further to give me the full liast of paths for each file and write to a log
Get-ChildItem -path c:\ -force -recurse | where {$_.length -eq 0} |Select-Object -Property FullName
Many Thanks
sjumu
folderPath = Wscript.Arguments(0)
maxFileAge = Wscript.Arguments(1)
countFiles = 0
Set fs = WScript.CreateObject ("Scripting.FileSystemObje
Set folder = fs.GetFolder(folderPath)
For Each file In folder.Files
If file.Size = 0 And DateDiff("n", file.DateLastModified, Now()) > Int(maxFileAge) Then
countFiles = countFiles + 1
End If
Next
If countFiles > 0 Then
WScript.Echo "Message: There are empty files older than " & maxFileAge & " minutes"
WScript.Echo "Statistic: " & countFiles
WScript.Quit( 1 )
Else
WScript.Echo "Message: There are no empty files older than " & maxFileAge & " minutes"
WScript.Echo "Statistic: " & countFiles
WScript.Quit( 0 )
End If