68 lines
1.7 KiB
Ruby
Executable file
68 lines
1.7 KiB
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
#
|
|
# Copyright (c) 2012 Ward Wouts <ward@wouts.nl>
|
|
#
|
|
# Permission to use, copy, modify, and distribute this software for any
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
# copyright notice and this permission notice appear in all copies.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
#
|
|
|
|
require 'getoptlong'
|
|
|
|
def usage
|
|
puts <<EOT
|
|
Usage: #{$0.sub(/.*\//, "")} [options] <file>
|
|
|
|
-u <arg> sth with argument
|
|
|
|
-d delete resulting files
|
|
-e escape output filenames with backslashes
|
|
-h, --help show this message
|
|
-l hardlink resulting files (no change if on
|
|
different filesystems)
|
|
-m mp3 compare, ignores ID3 tags (slow)
|
|
-s skip the first entry for doubles
|
|
|
|
EOT
|
|
exit
|
|
end
|
|
|
|
def cmdline
|
|
options = Hash.new
|
|
begin
|
|
opts = GetoptLong.new(
|
|
[ "-d", GetoptLong::REQUIRED_ARGUMENT ],
|
|
[ "-e", GetoptLong::REQUIRED_ARGUMENT ],
|
|
[ "-h", "--help", GetoptLong::NO_ARGUMENT ],
|
|
[ "-l", GetoptLong::REQUIRED_ARGUMENT ],
|
|
[ "-m", GetoptLong::REQUIRED_ARGUMENT ],
|
|
[ "-s", GetoptLong::REQUIRED_ARGUMENT ]
|
|
)
|
|
opts.quiet=true
|
|
|
|
opts.each do |opt, arg|
|
|
options[opt] = arg
|
|
end
|
|
|
|
rescue
|
|
print "#{$!}\n"
|
|
usage
|
|
end
|
|
if options["-h"]
|
|
usage
|
|
end
|
|
return options
|
|
end
|
|
|
|
options = cmdline
|
|
file = ARGV[0]
|
|
|