0 votes

I have a list of top level folders, that fall into the following categories:

  • some contain subfolders and files
  • others contain only subfolders.

Is it possible to identify the top level folders that meet the second criteria?

by (955 points)

1 Answer

0 votes
Best answer

Save the following script to a file (e.g. NoFiles.txt) and then specify it as the File name script in the Scripting Tab.

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

function isValidFileName( strPath, strFileName )
    // Open the folder and see if there are any subfolders but no files
    // Note: While this script will filter out only folders it is more efficient to
    // have the main search filter them out first by using Folders Only for the File name
    // expression type.
    var bIsValid = false;
        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;
by (31.5k points)
That was quick!
Just the trick - thanks alot.