Sha256: 0b262139bd585df30ef1c4d3e2505c9554381a6da0f39d33078fa17b22878360

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

#!/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] <folder>\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 <movie name>") do
        options[:imdb] = true
    end

    opts.on("-s","--singlemovie FILE","Acts on a single movie file <file name>") do |f|
        options[:single] = f
    end

    opts.on("-f","--folder FOLDER","Acts on whole folder <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] <name>\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 <filename>"
        exit 1
    end
    exit 0

elsif options[:imdb]
    MovieRenamer::imdbLookup(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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
movie-renamer-0.0.16 bin/movie-renamer