#!/usr/bin/ruby require File.join(File.dirname(__FILE__),'..','lib','movie-renamer') require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: #{File.basename($0)} [-i|-s|-f|-h|-p] \nDefault behavior is -f on current working directory" opts.on("-h","--help","Display this help") do puts opts exit 0 end opts.on("-i","--imdb","Executes a query on imdb on ") do options[:imdb] = true end opts.on("-s","--singlemovie FILE","Acts on a single movie file ") do |f| options[:single] = f end opts.on("-f","--folder FOLDER","Acts on whole folder ") do |f| options[:folder] = f end opts.on("-p","--path PATH", "path for moving renamed movies default is tmp/ in current working directory ") do |p| options[:path] = p end begin opts.parse!(ARGV) rescue OptionParser::ParseError => warn.message puts opts exit 1 end end name = ARGV.join(' ') =begin if options.length != 1 puts "Usage: #{File.basename($0)} [opts] \nOnly one options each run\nDefault behavior is -f on current working directory" end =end if options[:path] MovieRenamer::newpath = options[:path] end if options[:folder] MovieRenamer::folderPath = File.expand_path(options[:folder]) MovieRenamer::folderLoop() exit 0 elsif options[:single] if File.file?(File.expand_path(options[:single])) MovieRenamer::folderPath = File.dirname(File.expand_path(options[:single])) MovieRenamer::editMovie(options[:single]) else puts "Usage: #{File.basename($0)} -s " exit 1 end exit 0 elsif options[:imdb] MovieRenamer::suggestMovies(name) exit 0 elsif name MovieRenamer::folderPath = File.expand_path(name) MovieRenamer::folderLoop() exit 0 else Movierenamer::folderPath = Dir.pwd MovieRenamer::folderLoop() exit 0 end