Skip to content

Instantly share code, notes, and snippets.

@phase
Created March 19, 2016 18:12
Show Gist options
  • Save phase/52d73369b72968650966 to your computer and use it in GitHub Desktop.
Save phase/52d73369b72968650966 to your computer and use it in GitHub Desktop.
Groovy Script to rename a bunch of images by number
int count = 1
new File("C:/Users/phase/Pictures/FloridaVisits").eachFile() { file ->
if(file.getName().endsWith(".jpg")) {
String absolutePath = file.getAbsolutePath()
String filePath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator))
println file.getAbsolutePath() + " -> " + filePath+"\\"+count+".jpg"
file.renameTo(new File(filePath+"\\"+count+++".jpg"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment