Groovy: remove unexpected duplications of images

GroovyConsole with my code


Today i realised that in one of my photo album (“D:/Entertainment/photos/2010/20100814″) there are many duplications (one for each file).
It looked like here:

_MG_9884.CR2
_MG_9884.xmp
_MG_9884-1.CR2
_MG_9884-1.xmp

I thought it’s time for groovyConsole :-)
Solution was incredibly simple and intuitive:

new File("D:/Entertainment/photos/2010/20100814")
    .eachFileMatch(~/(.*?)-1\.(CR2|xmp)/){ file ->
        println file.name
        file.delete();
    }

Scala – save file to disk

var path:String = new File("./").getCanonicalPath+"/"
var file:String = path+"fileName.txt"
val writer = new PrintWriter( BufferedWriter(new FileWriter(file,false)));
writer.print(temp+" ")
writer.println("")
writer.close()