Skip to content

Instantly share code, notes, and snippets.

@mgdelacroix
Created April 16, 2012 10:04
Show Gist options
  • Save mgdelacroix/2397424 to your computer and use it in GitHub Desktop.
Save mgdelacroix/2397424 to your computer and use it in GitHub Desktop.
Rename a file in Groovy
def file = new File("/tmp/image.jpg")
println ">> Nombre del fichero: ${file.name}"
println "HACEMOS EL RENAME"
def string = "/tmp/${file.name[0..-5]}_thumb.jpg"
def newFile = new File(string)
file.renameTo(newFile)
println ">> Nombre del fichero: ${newFile.name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment