Sha256: e5b4f66124f1c44124f041fb8b75a1281b62b49371a8327c746a218ea99699ca

Contents?: true

Size: 1.96 KB

Versions: 6

Compression:

Stored size: 1.96 KB

Contents

#!/usr/bin/env 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

6 entries across 6 versions & 1 rubygems

Version Path
movie-renamer-0.0.22 bin/movie-renamer
movie-renamer-0.0.21 bin/movie-renamer
movie-renamer-0.0.20 bin/movie-renamer
movie-renamer-0.0.19 bin/movie-renamer
movie-renamer-0.0.18 bin/movie-renamer
movie-renamer-0.0.17 bin/movie-renamer