Skip to content

Instantly share code, notes, and snippets.

Created May 20, 2015 23:57
Show Gist options
  • Save anonymous/d1f5fd1f51d828dc2a3e to your computer and use it in GitHub Desktop.
Save anonymous/d1f5fd1f51d828dc2a3e to your computer and use it in GitHub Desktop.
// import de.sciss.file._
val fmtIn = new java.text.SimpleDateFormat("'B'HH'h'mm'm'ss's'ddMMMyyy'.wav'")
val fmtOut = new java.text.SimpleDateFormat("yyMMdd_HHmmss'.wav'")
def rename(dir: File, prefix: String): Unit = {
require(dir.isDirectory)
dir.children.foreach { fIn =>
try {
val date = fmtIn.parse(fIn.name)
val out = fmtOut.format(date)
val fOut = dir / s"$prefix$out"
import sys.process._
Seq("mv", fIn.path, fOut.path).!
} catch {
case _: java.text.ParseException =>
}
}
}
// rename(userHome/"Documents"/"devel"/"Configuration"/"rec", prefix = "config-")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment