Sha256: 92ce8967d8fa89457b8f6ac2cc01f0d0e4c75d3b4485fb1a6780d6f6f1370273

Contents?: true

Size: 1.96 KB

Versions: 2

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 => message
        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

2 entries across 2 versions & 1 rubygems

Version Path
movie-renamer-0.0.24 bin/movie-renamer
movie-renamer-0.0.23 bin/movie-renamer