Page 1 of 1
Finding Folders that do NOT Hold a Particular File?
Posted: 07 Sep 2009 13:17
by josepk
Hello,
I need to find a way to analyze several thousand folders/directories and determine if a particular file does NOT exist in each of these folders. Can I use XYplorer for this type of analysis? If so, how would I setup the search criteria?
Again, I only want the folders for which do not hold a certain file name to come back in the search results.
Thanks!
Joe
Re: Finding Folders that do NOT Hold a Particular File?
Posted: 07 Sep 2009 13:45
by admin
Hi,
interesting problem. Not possible currently with standard means. But there might be a way to get results using a script (no time to go into this now; somebody might help you here).
I wonder if anybody else could use such a functionality. I would not be hard to implement...
Don
Re: Finding Folders that do NOT Hold a Particular File?
Posted: 07 Sep 2009 14:05
by Stefan
admin wrote:
I wonder if anybody else could use such a functionality.
I have read this request from time to time.
People want to find music folders not containing a cover.JPG
or folders with .doc's but not containing an converted PDF file
or find folders without an error.log
so they know where the work waits for them.
This feature would have an use.
Re: Finding Folders that do NOT Hold a Particular File?
Posted: 07 Sep 2009 14:52
by josepk
My request is just that - to find music folders that do not contain a cover image file (e.g. folder.jpg).
This feature would be VERY useful to me. Maybe there is a way to script this somehow?
Joe
Re: Finding Folders that do NOT Hold a Particular File?
Posted: 07 Sep 2009 14:54
by jacky
For a basic thing, it sounds simple enough :
Code: Select all
"toto"
$folders = getinfo('SelectedItemsPathNames', '|');
$file = input('What file should NOT be in the selected folders?',,'XYplorer.exe');
$results = '';
$nb = 0;
$i = 1;
setting 'HideFoldersInList', 1;
$folder = gettoken($folders, $i, '|');
while ('' != $folder)
{
goto "$folder?$file /";
if (0 == getinfo('CountItems'))
{
$results = $results . $folder . <crlf>;
$nb++;
}
//
$i++;
$folder = gettoken($folders, $i, '|');
}
if (0 == $nb)
{
msg 'All folders contain a file ' . $file;
}
elseif (1 == $nb)
{
substr $results, $results, 0, -2;
msg "Only folder ""$results"" does NOT contain a file $file";
}
else
{
msg "The following $nb folders do NOT contain a file $file :<br><br>$results";
}
This script will search for the file you specify in each of the selected folders, and then tell you which folder do NOT contain such a file. Quick notes:
- All folders must be selected, but if they're not all under the same parent you could simply either a search and select them from search results (or put their full path/names manually in the script...).
- The file you're asked for (that shout not be in folders) is really a search criteria, so a full pattern e.g. "*.rar;*.zip" will work fine.
- The search is run in every selected folders only (i.e. no subfolders)
- I've hidden folders on List (the setting call) before running the searches to ensure only files are found (no folders)
- I just wrote that as a way to procrastinate, no guarantee of anything

Re: Finding Folders that do NOT Hold a Particular File?
Posted: 07 Sep 2009 17:53
by j_c_hallgren
Hi and welcome to the XY forums, Joe!
As you've seen already, we can provide an answer pretty quickly here!
Don replied within the hour and others as well...that's what makes XY special and hope that will make you a "lifetime" user if you're not already one.
And I've had a couple of times when I could have used this "missing file" function but just did it manually by searching for the file and seeing what expected paths did NOT show in the results.
I suspect jacky's script would do until such time as a built-in function might be added, if it's even needed now with this script, which could be easily tweaked if necessary.
Re: Finding Folders that do NOT Hold a Particular File?
Posted: 19 Dec 2014 21:51
by admin
Comes tomorrow to your homes...

Re: Finding Folders that do NOT Hold a Particular File?
Posted: 20 Dec 2014 13:28
by RalphM
That wish took rather long for XY standards to come to light...