2012-11-16 23:14:09 -05:00
|
|
|
// filebot -script fn:revert <file or folder>
|
|
|
|
|
|
|
|
|
|
|
|
def accept(from, to) {
|
|
|
|
args.find{ to.absolutePath.startsWith(it.absolutePath) } && to.exists()
|
|
|
|
}
|
|
|
|
|
|
|
|
def revert(from, to) {
|
|
|
|
def action = net.sourceforge.filebot.StandardRenameAction.forName(_args.action)
|
|
|
|
|
|
|
|
println "[$action] Revert [$from] to [$to]"
|
2013-08-06 22:58:45 -04:00
|
|
|
if (!from.canonicalFile.equals(to.canonicalFile)) {
|
|
|
|
action.rename(from, to) // reverse-rename only if path has changed
|
|
|
|
}
|
2013-03-07 09:11:23 -05:00
|
|
|
|
|
|
|
// reset extended attributes
|
|
|
|
tryQuietly{ to.xattr.clear() }
|
2012-11-16 23:14:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getRenameLog(true).reverseEach { from, to ->
|
|
|
|
if (accept(from, to))
|
|
|
|
revert(to, from)
|
|
|
|
}
|