Wednesday, February 27, 2008

groovy script to rename a lot of files

I got a hold of 1692 mp3 files of Chinese characters for a Chinese-English dictionary that I wrote with my 16year old cousin to introduce him to programming in Groovy. The dictionary is called xiaosu cidian 小苏词典 http://www.diningphilosophers.net/xiaosu

The mp3 files are all in uppercase but I wanted them in lower case. Here's the script I wrote to do that:


new File(".").eachFile{ f->
def cmd = "mv $f.name ${f.name.toLowerCase()}"
cmd.execute()
}


Much easier than with Java!

No comments: