Created
July 17, 2009 13:12
-
-
Save loverdos/149042 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.System | |
import java.io.File | |
import java.util.regex.Pattern | |
val Path = System.getenv("PATH") | |
val PathSep = File.pathSeparator | |
val pathFolders = Path.split(PathSep).toList.map(new File(_)).filter { file => | |
if(file.isDirectory) { | |
file.listFiles match { | |
case null => false | |
case _ => true | |
} | |
} else { | |
false | |
} | |
} | |
val names = args map (_.toLowerCase) | |
//println(pathFolders) | |
names foreach { name => | |
println("--- " + name + " --->") | |
var counter = 0 | |
pathFolders foreach { folder => | |
val children = folder.list | |
val found = children filter { child => | |
if(child.toLowerCase.indexOf(name) > -1) { | |
true | |
} else if (Pattern.compile(name, Pattern.CASE_INSENSITIVE).matcher(child).find) { | |
true | |
} else { | |
false | |
} | |
} | |
if(found.size > 0) { | |
if(folder.getAbsolutePath.indexOf(" ") > -1) { | |
println("\"" + folder + "\":") | |
} else { | |
println(folder + ":") | |
} | |
println(" " + found.mkString(", ")) | |
} | |
counter += found.size | |
} | |
// if(counter > 0) | |
println() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment