Skip to content

Instantly share code, notes, and snippets.

@joerodriguez
Created November 26, 2013 02:12
Show Gist options
  • Save joerodriguez/7652481 to your computer and use it in GitHub Desktop.
Save joerodriguez/7652481 to your computer and use it in GitHub Desktop.
filebot movie renamer
// PERSONALIZED SETTINGS
def movieDir = '''/in/Movies'''
def movieFormat = '''/out/Movies/{n} ({y})/{n} ({y}){" CD$pi"}'''
// ignore chunk, part, par and hidden files
def incomplete(f) { f.name =~ /[.]incomplete|[.]chunk|[.]par$|[.]dat$/ }
// extract completed multi-volume rar files
[movieDir].getFolders{ !it.hasFile{ incomplete(it) } && it.hasFile{ it =~ /[.]rar$/ } }.each{ dir ->
// extract all archives found in this folder
def paths = extract(folder:dir)
// delete original archive volumes after successful extraction
if (paths != null && !paths.isEmpty()) {
dir.listFiles{ it =~ /[.]rar$|[.]r[\d]+$/ }*.delete()
}
}
movieDir.getFolders{ !it.hasFile{ incomplete(it) } && it.hasFile{ it.isVideo() } }.each{ dir ->
println "Processing $dir"
def files = dir.listFiles{ it.isVideo() }
// sort movies / subtitles
rename(file:files, db:'TheMovieDB', format:movieFormat)
// fetch subtitles
files += getSubtitles(file:files)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment