Created
October 10, 2010 07:31
-
-
Save osima/619059 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
// g100pon #23 ディレクトリを走査して特定のファイルを抽出 | |
// | |
// 例 : カレントディレクトリ以下にある htmlファイル を列挙 | |
// groovy findfile '.*.html' | |
// | |
if( args.length<1 ){ | |
println 'Usage: groovy findfile regex' | |
System.exit(0) | |
} | |
regex = args[0] | |
recur = { | |
if( it.isDirectory() ) | |
it.listFiles().each{ recur(it) } | |
else | |
if( java.util.regex.Pattern.compile(regex).matcher( it.name ).find() ) | |
println it.canonicalPath | |
} | |
recur(new File('.')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment