2012-10-04

Groovy one-liner to extract file name without extension

Does groovy have an easy way to get a filename without the extension? - Stack Overflow:

file.name.lastIndexOf('.').with {it != -1 ? file.name[0..<it] : file.name}

 or with a simple regexp:

file.name.replaceFirst(~/\.[^\.] $/, ''

No comments: