fork download
  1. import java.io.File
  2.  
  3. fun main(args: Array<String>) {
  4. val ptn = Regex("""(.*?)(\d+)(\.[^.]*)?""")
  5. File(".").listFiles()
  6. .mapNotNull { ptn.matchEntire(it.name)?.groupValues }
  7. .forEach { File(it[0]).renameTo(
  8. File(it[1] + it[2].padStart(3, '0') + it[3])) }
  9. }
  10.  
Success #stdin #stdout 0.09s 34932KB
stdin
Standard input is empty
stdout
Standard output is empty