1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-17 23:05:03 -05:00
filebot/website/scripts/revert.groovy

23 lines
480 B
Groovy
Raw Normal View History

// 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]"
action.rename(from, to)
2013-03-07 09:11:23 -05:00
// reset extended attributes
tryQuietly{ to.xattr.clear() }
}
getRenameLog(true).reverseEach { from, to ->
if (accept(from, to))
revert(to, from)
}