#!/usr/bin/env groovy
@Grab("commons-io:commons-io:2.6")
import org.apache.commons.io.FileUtils
static String getSeparator() {
System.getProperty("file.separator")
}
String from = "${System.getProperty("user.home")}${separator}.config${separator}transmission${separator}torrents"
String to = "${System.getProperty("user.home")}${separator}Documents${separator}torrents_completed"
File fromDlDir = new File("${System.getProperty("user.home")}${separator}Téléchargements")
File fromDir = new File(from)
File toDir = new File(to)
Collection<File> torrentFiles = FileUtils.listFiles(
fromDir,
["torrent"] as String[],
false)
torrentFiles.addAll(FileUtils.listFiles(
fromDlDir,
["torrent", "torrent.added"] as String[],
false))
torrentFiles.empty ?: torrentFiles.each { it ->
FileUtils.copyFileToDirectory(it, toDir)
}
println torrentFiles.size()