Empty folders

H

Helge Haensel

Hallo NG!

W7/64 Home Premium.
I have a folder-tree that ends in many empty folders.
Does someone now a tool that counts (and can delete)
the empty ones, a batch eventually?
Thanks.

Vy 73! Helge
 
P

philo 

Hallo NG!

W7/64 Home Premium.
I have a folder-tree that ends in many empty folders.
Does someone now a tool that counts (and can delete)
the empty ones, a batch eventually?
Thanks.

Vy 73! Helge


If you have "hidden" files the folders may possibly not be empty.

The amount of space any empty folder takes is so small, I would just not
worry about them
 
P

Paul

Helge said:
Hallo NG!

W7/64 Home Premium.
I have a folder-tree that ends in many empty folders.
Does someone now a tool that counts (and can delete)
the empty ones, a batch eventually?
Thanks.

Vy 73! Helge
http://www.winfrastructure.net/article.aspx?BlogEntry=VBScript-to-check-if-folder-is-empty

If objFolder.Files.Count = 0 And objFolder.SubFolders.Count = 0 Then
MsgBox "The folder is empty"

Then all you need, is some recursive code to walk
the file tree. I got a chunk of that around here
somewhere... Got it off the web. Store in file
"listdir5.vbs". You'll need to combine the contents from
the above link, into some directory traversing code
like this example. Google on scanSubFolders(objFolder)
for more examples.

' // **************************************
' // Script to list files.
' // List is tab separated.
' // Based on someone elses script, with slight changes.
' // Output looks like this. (Size <tab> Date <tab> Path)
' //
' // 32964 1/19/2012 1:06:32 AM C:\test.txt
' //
' // This program has no command line arguments. You enter the
' // topDir as a string in the line below. That's where it'll start
' // scanning. The output always goes to ScriptOutput1.txt . Change
' // the name to something you like.
' //
' // Program has no error handling. I just changed another script, to make this one.

Dim objFSO
Dim tab
tab=chr(9)

topDir = "C:\Downloads\contig_test\hello\"
set objFSO = CreateObject("Scripting.FileSystemObject")

' Create text file to store output data
' When you launch this in MSDOS window, file will be created in current working directory.
Set OutputFile = objFSO.CreateTextFile("ScriptOutput1.txt", True)

Set objFolder = objFSO.GetFolder(topDir)
Set colFiles = objFolder.Files
Set colFolders = objFolder.SubFolders

For Each objFile in colFiles
Outputfile.write(objFile.size)
Outputfile.write(tab)
Outputfile.write(objFile.DateLastModified)
Outputfile.write(tab)
Outputfile.writeLine(objFile.Path)
Next

' Call a separate subroutine, to output file contents of subfolders

For Each objSubFolder In colFolders
ScanSubFolders(objSubFolder)
Next

' Close text file
OutputFile.Close
' Program ends here...

' // **************************************
Sub scanSubFolders(objFolder)

Set colFiles = objFolder.Files
Set colFolders = objFolder.SubFolders

For Each objFile in colFiles
Outputfile.write(objFile.size)
Outputfile.write(tab)
Outputfile.write(objFile.DateLastModified)
Outputfile.write(tab)
Outputfile.writeLine(objFile.Path)
Next

For Each objSubFolder In colFolders
ScanSubFolders(objSubFolder)
Next

End Sub
*******

HTH,
Paul
 
H

Helge Haensel

Hallo NG!

W7/64 Home Premium.
I have a folder-tree that ends in many empty folders.
Does someone now a tool that counts (and can delete)
the empty ones, a batch eventually?
Thanks.

Vy 73! Helge
Well, thanks for your examples. I'll check them.
 
E

Ed Cryer

Yousuf said:
Yes, I second that one. I've used it for a number of years.

Yousuf Khan
I ran it and got this result;
Found 2637 empty directories (checked 28943 / runtime: 01.05 min)

Sheesh! So I started looking into things.
One thing I found is in the Mozilla cache under AppData. There are
strings of empty folders inside "Profiles", and they have today's date
on them. Presumably tomorrow they'll have that date after Firefox's
first run.
What the dickens??? I can see just why Helge is concerned if he's seen
those.

Ed
 
Y

Yousuf Khan

I ran it and got this result;
Found 2637 empty directories (checked 28943 / runtime: 01.05 min)

Sheesh! So I started looking into things.
One thing I found is in the Mozilla cache under AppData. There are
strings of empty folders inside "Profiles", and they have today's date
on them. Presumably tomorrow they'll have that date after Firefox's
first run.
What the dickens??? I can see just why Helge is concerned if he's seen
those.

Ed
I personally wouldn't worry about empty directories, they are often
created by programs for their own internal purposes, and they don't take
up any real space on the drive. It just seems unsightly, like dust
bunnies in the house, which in the end are also useless to worry about.

Also I wouldn't run RED over the entire disk, but just go through some
specific sub-folder hierarchy.

Yousuf Khan
 
E

Ed Cryer

Helge said:
Well, tried this one, great.
Result:
Thu, 15 Aug 2013 14:09:39 GMT Found 1423 empty directories (checked
23854 / runtime: 00:55 min)
Helge
That's far fewer than I have!
I'd leave it alone, myself. Take the advice given by Yousuf Khan.
They take up little room (quite a lot of space in the indexes, but
ignore that), and you'd probably cause problems by erasing them ad lb.

How big is your hard drive? Mine's large enough to handle it all.

Ed
 
H

Helge Haensel

That's far fewer than I have!
I'd leave it alone, myself. Take the advice given by Yousuf Khan.
They take up little room (quite a lot of space in the indexes, but
ignore that), and you'd probably cause problems by erasing them ad
lb.

How big is your hard drive? Mine's large enough to handle it all.

Ed
Well, thanks to you all you guys. I'll follow your advice. HD 1 Tb.
Helge
 
E

Ed Cryer

Char said:
That's the program I use. Works a treat, as the kids say.
A bit scary, though, when you get the results.
Have you seen my comments above after its first outing on my PC?

Ed
 
C

Char Jackson

A bit scary, though, when you get the results.
Have you seen my comments above after its first outing on my PC?
I've just finished posting to the 'libraries are dangerous!' thread, so I'm
maxed out on scary right now. I have none to spare for this thread. :)

I would never use such a tool on an entire system volume. I limit it to a
folder structure that I've created and now I want to clean up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top