How to search the deepest folder or files with everything?

Have a suggestion for "Everything"? Please post it here.
Post Reply
qwop
Posts: 2
Joined: Thu Mar 07, 2013 3:35 am

How to search the deepest folder or files with everything?

Post by qwop »

Search the deepest folder or file ..
Search the deepest folder without the file which some like *.jar


deepest: without:*.jar

deepest: with:*.jar
void
Developer
Posts: 17153
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to search the deepest folder or files with everythin

Post by void »

There is no option to search the deepest folders, you might be able to use the parents: macro.
The parents: macro allows you to specify the number of parents a file or folder must have.
For example, files and folders with more than 5 parents:

Code: Select all

parents:>5
To exclude a search, prefix a !
For example, to exclude *.jar:

Code: Select all

!*.jar
qwop
Posts: 2
Joined: Thu Mar 07, 2013 3:35 am

Re: How to search the deepest folder or files with everythin

Post by qwop »

implement by the java , myself

Code: Select all

package com.tan;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;

/**
 * @author qwop
 *
 */
public class DeepestMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		File root = new File( System.getProperty( "user.home" ) + 
				File.separator + ".m2" + 
				File.separator + "repository" 
	    );
		
		final List<File> deepestFolders = new ArrayList<File>();
		root.listFiles( new FileFilter() {
			@Override
			public boolean accept(File pathname) {
				if ( pathname.isDirectory() ) {
					pathname.listFiles( this );
					
					if ( !hadChildFolder( pathname ) ) {
						deepestFolders.add( pathname );
					}
				}
				return false; // ignore the result.
			}
		});
		
		System.out.println( deepestFolders.size() );
	}
	
	
	public static boolean hadChildFolder( final File folder ) {
		File[] files = folder.listFiles();
		
		for ( File file : files ) {
			if ( file.exists() && file.isDirectory() ) 
				return true;
		}
		
		return false;
	}

}
Post Reply