+1 vote

Hello.

Is it possible to generate a list of ONLY subfolders, and exclude all of the parent folders?

For example: Let’s say I have a folder named “The Story of Lester.” In that folder are three subfolders, named Prologue, Chapter One, and Epilogue.

Is it possible to generate a list that has those three subfolders, but not the folder named The Story of Lester?

If this is possible, what is the procedure? Also, can I generate a list that contains the subfolders of several parent folders, and exclude the names of all of their parent folders?

Thank you.

PS: I'm interested only in folders and not files. (I exclude files by setting the file size to less than one byte.)

by (25 points)

1 Answer

0 votes

If you wanted to search for only folders that had no subfolders (ie the leaf subfolders) you could do that with a script. Something like:

// This script returns all folders that do not have any subfolders
	
var objFSO = new ActiveXObject( "Scripting.FileSystemObject" );

function isValidFileName( strPath, strFileName )
{
	// Open the folder and see if there are any subfolders 
	
	try
	{
		var strFolderPath = strPath + strFileName
		if ( objFSO.FolderExists( strFolderPath ) )
		{
			var folderCheck = objFSO.GetFolder( strFolderPath );
			var subfolders = folderCheck.SubFolders;
			return subfolders.Count == 0;
		}
	}
	catch( e )	{
	}
	return false;
}

How to use the script

Step 1. Save the script in a file, e.g. folders_leaf_only.js

Step 2. Set the search to Folders Only

Folders Only

Step 3. Specify the script in the File name script

Leaf folders only

Step 4. Run the search

Results

by (30.1k points)
...