Finding Folders that do NOT Hold a Particular File?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
josepk
Posts: 2
Joined: 06 Sep 2009 21:28

Finding Folders that do NOT Hold a Particular File?

Post 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

admin
Site Admin
Posts: 66323
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Finding Folders that do NOT Hold a Particular File?

Post 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

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Finding Folders that do NOT Hold a Particular File?

Post 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.

josepk
Posts: 2
Joined: 06 Sep 2009 21:28

Re: Finding Folders that do NOT Hold a Particular File?

Post 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

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Finding Folders that do NOT Hold a Particular File?

Post 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 :P
Proud XYplorer Fanatic

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Finding Folders that do NOT Hold a Particular File?

Post 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.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

admin
Site Admin
Posts: 66323
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Finding Folders that do NOT Hold a Particular File?

Post by admin »

Comes tomorrow to your homes... :)

RalphM
Posts: 2089
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Finding Folders that do NOT Hold a Particular File?

Post by RalphM »

That wish took rather long for XY standards to come to light...
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

Post Reply