How list all non-empty subfolders in a folder ?

  • Thread starter Thread starter MoiMeme
  • Start date Start date
M

MoiMeme

Hi,

I have a folder with a complex sub-sub-folders structure

I need to know wich ones are NOT empty

Any way either using DOS or script ?

TIA !!!
 
MoiMeme said:
Hi,

I have a folder with a complex sub-sub-folders structure

I need to know wich ones are NOT empty

Any way either using DOS or script ?

TIA !!!

Do you consider a folder empty if it contains no files but other folders?
 
yes, in this particular case, since I need to know if some of these
subfolders contain files, so I can save them and delete the structure.
But being that complex, it involves much clicking to manually check all of
them
 
Your reply is contradictory. I asked:
"Do you consider a folder empty if it contains no files but other folders?"

and you replied:
"Yes".

Then you imply that you DON'T consider them empty, because
they might contain files. Before I try to give you a solution
I need to know in no uncertain terms the answer to my
question.
 
Indeed not correctly stated
What I need to detect are folders that do contain files

If yes then i have to gather the files it contains
If no files and no subfolders then I can erase the folder
 
You could run the following batch file. Make sure to copy
& paste it - do NOT retype it!

==============================
@echo off
Set Folder=D:\My Documents

rem Unwrap the lines below so that they
rem all start with the word "echo"!

echo Empty folder list:
echo > c:\TempVBS.vbs const FolderName = "%Folder%"
echo >> c:\TempVBS.vbs Set objFSO =
CreateObject("Scripting.FileSystemObject")
echo >> c:\TempVBS.vbs CheckFolder(FolderName)
echo >> c:\TempVBS.vbs Sub CheckFolder(Name)
echo >> c:\TempVBS.vbs Set folder = objFSO.GetFolder(Name)
echo >> c:\TempVBS.vbs Set objFolders = folder.SubFolders
echo >> c:\TempVBS.vbs Set objFiles = folder.Files
echo >> c:\TempVBS.vbs If objFolders.Count + objFiles.Count = 0 Then
WScript.Echo Name
echo >> c:\TempVBS.vbs For Each FldrName In objFolders
echo >> c:\TempVBS.vbs CheckFolder(FldrName)
echo >> c:\TempVBS.vbs Next
echo >> c:\TempVBS.vbs End Sub

rem The lines below this point do NOT start
rem with the word "echo"!
cscript //nologo c:\TempVBS.vbs
del c:\TempVBS.vbs

==============================
 

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

Back
Top