?
Solved

Script to List 0kb files

Posted on 2013-01-30
4
Medium Priority
?
688 Views
Last Modified: 2013-02-01
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
0
Comment
Question by:sjumu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:alphaphaedrus
ID: 38835632
Dim folderPath, maxFileAge, countFiles

folderPath = Wscript.Arguments(0)
maxFileAge = Wscript.Arguments(1)
countFiles = 0

Set fs = WScript.CreateObject ("Scripting.FileSystemObject")
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
0
 

Author Comment

by:sjumu
ID: 38835931
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
0
 
LVL 40

Accepted Solution

by:
footech earned 1600 total points
ID: 38836072
If you're open to PowerShell, this should work for you.
Get-ChildItem -path c:\ -force -recurse | where {$_.length -eq 0}

Open in new window

Just change the path to where you want to search.  With the recurse parameter it will search all subfolders.  An error will be displayed for any files that you don't have access to.  If you don't want those errors displayed you can change the command to
Get-ChildItem -path c:\ -force -recurse -ea SilentlyContinue | where {$_.length -eq 0}

Open in new window

0
 

Author Comment

by:sjumu
ID: 38843133
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question