Sha256: b8a76cfe5bf917a9e1fb9d7c40e602a389b167d0190da115084910441bcd52a4
Contents?: true
Size: 828 Bytes
Versions: 2
Compression:
Stored size: 828 Bytes
Contents
#! /usr/bin/ruby -w # coding: utf-8 # 拡張子は保存 # -i オプションで開始番号を指定 # -p : preserve old name 元のファイル名を残す。foo.txt -> 001-foo.txt require "filerenamer/filerenamer.rb" require "filerenamer/filerenameroptionparser.rb" OPTIONS = {} op = FileRenamerOptionParser.new op.on("-i num", "--initial", "Indicate initial number."){ |val| OPTIONS[:init] = val.to_i } op.on("-p", "--preserve", "Preserve old name."){ OPTIONS[:preserve] = true } op.parse!(ARGV) OPTIONS[:init] ||= 0 fr = FileRenamer.new(op.options) fr.execute(ARGV) do |filename| @counter ||= OPTIONS[:init] if (OPTIONS[:preserve]) new_name = sprintf("%03d-%s", @counter, filename) else extention = File.extname(filename) new_name = sprintf("%03d%s", @counter, extention) end @counter += 1 new_name end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
filerenamer-0.0.1 | bin/filenameNumber |
filerenamer-0.0.0 | bin/filenameNumber |