Guest User

Untitled

a guest
Jun 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. // g100pon #23 ディレクトリを走査して特定のファイルを抽出
  2. //
  3. // 例 : カレントディレクトリ以下にある htmlファイル を列挙
  4. // groovy findfile '.*.html'
  5. //
  6.  
  7. if( args.length<1 ){
  8. println 'Usage: groovy findfile regex'
  9. System.exit(0)
  10. }
  11.  
  12. regex = args[0]
  13.  
  14. recur = {
  15. if( it.isDirectory() )
  16. it.listFiles().each{ recur(it) }
  17. else
  18. if( java.util.regex.Pattern.compile(regex).matcher( it.name ).find() )
  19. println it.canonicalPath
  20. }
  21.  
  22. recur(new File('.'))
Add Comment
Please, Sign In to add comment