Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Copies all MP3-files in a directory to another directory in a random order.
import java.nio.file.{ Files, StandardCopyOption }
import java.util.{ Collections, Random }
import scala.collection.JavaConversions
object RandomCopy extends App {
val src = new File("""E:\Backup\Auto""")
val dest = new File("""F:\""")
val files =
val seed = System.nanoTime
Collections.shuffle(files, new Random(seed))
var i = 1
val fs = JavaConversions.iterableAsScalaIterable(files)
for (f <- fs) {
val newPath = new File(dest, f.getName).toPath
Files.copy(f.toPath, newPath, StandardCopyOption.REPLACE_EXISTING)
println(i + "/" + fs.size + ", " + f.getName)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.