Skip to content

Instantly share code, notes, and snippets.

@masanobuimai
Created October 10, 2010 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masanobuimai/619348 to your computer and use it in GitHub Desktop.
Save masanobuimai/619348 to your computer and use it in GitHub Desktop.
// g100pon #28 ファイル名の一括置換
//
import groovy.io.FileType
// 開始ディレクトリや探索方法は適当に直して
new File("../").eachFileRecurse(FileType.FILES) { file ->
// とりあえずファイル名を置換してみる(変換パターンも適当に直して)
def newFileName = file.name.replaceAll(/.class$/, ".clazz")
if (file.name != newFileName) {
// 置換できてれば、実ファイルをリネームする
def newFile = new File("${file.parentFile}${File.separator}${newFileName}")
println "$file >> $newFile"
file.renameTo(newFile)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment