Mythicsoft Knowledge Base

Full Text Search

Searching for empty folders

 

FileLocator Pro can search for folders by setting the 'Folder = On' attribute in the Attributes tab. To search for only those folders that are empty, however, requires a little bit of scripting.

Steps for searching for empty folders:

1. Set the 'Folder = On' attribute in the Attributes tab. 2. Set the 'File name' script in the scripting tab to active. 3. Select the script 'empty_folders.js' from the Sample Scripts folder 5. Set the Engine to JScript.

That's it. Don't forget to switch those settings off when you've finished and you want to perform regular searches.



----------------

Script: empty_folders.js

var objFSO = new ActiveXObject( "Scripting.FileSystemObject" );

function isValidFileName( strPath, strFileName )
{
    // Open the folder and see if there are any subfolders or files
    // Note: While this script will filter out only folders it is more 
    // efficient to have the main search filter them out first by 
    // setting the 'Folders = On' attribute in the Attributes tab.
 
    var bIsValid = false;
    try
    {
        var strFolderPath = strPath + strFileName
  
        if ( objFSO.FolderExists( strFolderPath ) )
        {
            var folderCheck = objFSO.GetFolder( strFolderPath );
            bIsValid = ((folderCheck.SubFolders.Count == 0) 
                        && (folderCheck.Files.Count == 0));   
        }
    }
    catch( e ) {}
    return bIsValid;
}

 

Mythicsoft KB powered by ScrewTurn Wiki. Some of the icons created by FamFamFam.