bvwack 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -0
- data/lib/bvwack/bvwack_version.rb +1 -1
- data/lib/bvwack/convert.rb +103 -71
- data/pkg/bvwack-0.0.2/README.md +25 -0
- data/pkg/bvwack-0.0.2/Rakefile +7 -0
- data/pkg/bvwack-0.0.2/bin/bvwack +3 -0
- data/pkg/bvwack-0.0.2/bvwack.gemspec +19 -0
- data/pkg/bvwack-0.0.2/lib/bvwack/bvwack_version.rb +3 -0
- data/pkg/bvwack-0.0.2/lib/bvwack/convert.rb +252 -0
- data/pkg/bvwack-0.0.2/lib/bvwack.rb +1 -0
- data/pkg/bvwack-0.0.2.gem +0 -0
- metadata +10 -1
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# bvwack - Bulk Convert video files
|
2
|
+
|
3
|
+
Author:: Robie Lutsey
|
4
|
+
|
5
|
+
Copyright:: Copyright (c) 2012 by Robie Lutsey
|
6
|
+
License:: Distributed under the Apache License
|
7
|
+
|
8
|
+
bvwack (sounds like bivouc) is a dead simple tool for converting logs of video files.
|
9
|
+
Currently it supports .avi and .mkv --> iPad compatible .mp4.
|
10
|
+
|
11
|
+
## Install
|
12
|
+
|
13
|
+
gem install bvwack
|
14
|
+
|
15
|
+
## Use
|
16
|
+
|
17
|
+
bvwack -[wc] < -n # -b base-dir >
|
18
|
+
|
19
|
+
For more help:
|
20
|
+
|
21
|
+
bvwack --help
|
22
|
+
|
23
|
+
## Developing for `bvwack`
|
24
|
+
|
25
|
+
TODO
|
data/lib/bvwack/convert.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
|
3
|
-
DEFAULT_CONVERT_BASE_DIR = "
|
4
|
-
DEFAULT_CLEAN_BASE_DIR = "/
|
3
|
+
DEFAULT_CONVERT_BASE_DIR = "#{ENV['PWD']}"
|
4
|
+
DEFAULT_CLEAN_BASE_DIR = "#{ENV['PWD']}/bvwack-back"
|
5
5
|
FFMPEG_OPTS = "-acodec aac -ac 2 -ab 160k -s 1024x768 -vcodec libx264 -vpre slow -vpre iPod640 -vb 1200k -f mp4 -threads 2 -strict experimental"
|
6
6
|
help_text = "
|
7
7
|
Usage: bvwack <options>
|
@@ -20,13 +20,20 @@ Notes: By default this will not work for you. You must change DEFAULT_CONVERT_BA
|
|
20
20
|
the clean dir be a subdirectory of base dir or you'll be sad. I have set the
|
21
21
|
FFMPEG options to use only 2 threads. This allows me to use my laptop while
|
22
22
|
converting things. If you just want to hog through video try setting -threads 0
|
23
|
-
in FFMPEG_OPTS.
|
23
|
+
in FFMPEG_OPTS. Currently this only works on UNIX-like systems.
|
24
|
+
|
25
|
+
Requirements: ffmpeg and a libx264-slow.ffpreset (possibly in your ~/.ffmpeg/ directory or in your Cellar if you use brew.) Google is your friend.
|
24
26
|
|
25
27
|
Examples:
|
26
28
|
bvwack -dw Shows proposed commands for 2 videos
|
27
29
|
bvwack -w -b somedir/anotherdir -n 5 Converts 5 videos under somedir/anotherdir
|
28
30
|
bvwack -c -n 10 Moves 10 already converted mkv or avi files to /Volumes/thundar/medai/converted/[od-path]"
|
29
31
|
|
32
|
+
@converted_files = { }
|
33
|
+
@not_converted_files = { }
|
34
|
+
@to_convert = []
|
35
|
+
|
36
|
+
|
30
37
|
options = { }
|
31
38
|
option_parser = OptionParser.new do |opts|
|
32
39
|
opts.on("-d", "--dry-run") do
|
@@ -58,12 +65,26 @@ option_parser = OptionParser.new do |opts|
|
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
68
|
+
def echo_base_dirs(options)
|
69
|
+
if options[:base_dir]
|
70
|
+
puts "\nOperating in #{ options[:base_dir]}"
|
71
|
+
puts "I will create #{ options[:base_dir]}/bvwack-back to store converted files if you use clean-up.\n\n"
|
72
|
+
else
|
73
|
+
puts "\nOperating in #{DEFAULT_CONVERT_BASE_DIR}"
|
74
|
+
puts "I will create #{ DEFAULT_CLEAN_BASE_DIR} to store converted files if you use clean-up.\n\n"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
61
78
|
def convert(path_to_file)
|
62
|
-
|
79
|
+
if path_to_file.class == String
|
80
|
+
`ffmpeg -i "#{path_to_file}" #{FFMPEG_OPTS} "#{path_to_file.gsub(/mkv$|avi$/, "ipad.mp4")}"`
|
81
|
+
end
|
63
82
|
end
|
64
83
|
|
65
84
|
def dry_run(path_to_file)
|
66
|
-
|
85
|
+
if path_to_file.class == String
|
86
|
+
puts "ffmpeg -i #{path_to_file} #{FFMPEG_OPTS} #{path_to_file.gsub(/mkv$|avi$/, "ipad.mp4")}\n\n"
|
87
|
+
end
|
67
88
|
end
|
68
89
|
|
69
90
|
|
@@ -81,86 +102,96 @@ def get_files(args)
|
|
81
102
|
end
|
82
103
|
end
|
83
104
|
|
84
|
-
@converted_files = { }
|
85
|
-
@not_converted_files = { }
|
86
105
|
|
87
|
-
def get_all_files(
|
106
|
+
def get_all_files(options)
|
107
|
+
if options[:base_dir]
|
108
|
+
base_dir = options[:base_dir]
|
109
|
+
else
|
110
|
+
base_dir = DEFAULT_CONVERT_BASE_DIR
|
111
|
+
end
|
88
112
|
Dir.chdir(base_dir)
|
89
113
|
converted_files = Dir.glob(File.join("**", "*ipad.mp4"))
|
90
114
|
converted_files.each do |i|
|
91
|
-
|
115
|
+
if i.include?("bvwack-back")
|
116
|
+
next
|
117
|
+
else
|
118
|
+
@converted_files[File.basename(i, ".ipad.mp4")] = i
|
119
|
+
end
|
92
120
|
end
|
121
|
+
|
93
122
|
not_converted_files = Dir.glob(File.join("**", "*.{mkv,avi}"))
|
94
123
|
not_converted_files.each do |i|
|
95
|
-
if
|
96
|
-
|
97
|
-
|
98
|
-
|
124
|
+
if i.include?("bvwack-back")
|
125
|
+
next
|
126
|
+
else
|
127
|
+
if File.basename(i).split(".").last == "mkv"
|
128
|
+
@not_converted_files[File.basename(i, ".mkv")] = i
|
129
|
+
elsif File.basename(i).split(".").last == "avi"
|
130
|
+
@not_converted_files[File.basename(i, ".avi")] = i
|
131
|
+
end
|
99
132
|
end
|
100
133
|
end
|
101
134
|
end
|
102
135
|
|
103
|
-
@to_convert = []
|
104
|
-
|
105
136
|
def get_unconverted_files(converted_files, not_converted_files)
|
106
137
|
(not_converted_files.keys - converted_files.keys).each do |key|
|
107
138
|
@to_convert << @not_converted_files[key]
|
108
139
|
end
|
109
140
|
end
|
110
141
|
|
111
|
-
def clean_up
|
142
|
+
def clean_up(options)
|
143
|
+
if options[:base_dir]
|
144
|
+
clean_dir = "#{options[:base_dir]}/bvwack-back"
|
145
|
+
else
|
146
|
+
clean_dir = DEFAULT_CONVERT_BASE_DIR
|
147
|
+
end
|
112
148
|
if @to_clean.length > 0
|
113
149
|
key = @to_clean.pop
|
114
150
|
filename = @not_converted_files[key]
|
115
151
|
dirname = File.dirname(@not_converted_files[key])
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
else
|
120
|
-
puts "No more files to clean. Hooray!"
|
152
|
+
`mkdir -p "#{clean_dir}/#{dirname}" && mv "#{filename}" "#{clean_dir}/#{filename}"`
|
153
|
+
#else
|
154
|
+
# puts "No more files to clean. Hooray!"
|
121
155
|
end
|
122
156
|
end
|
123
157
|
|
124
|
-
def dry_clean_up
|
158
|
+
def dry_clean_up(options)
|
159
|
+
if options[:base_dir]
|
160
|
+
clean_dir = "#{options[:base_dir]}/bvwack-back"
|
161
|
+
else
|
162
|
+
clean_dir = DEFAULT_CONVERT_BASE_DIR
|
163
|
+
end
|
125
164
|
if @to_clean.length > 0
|
126
165
|
key = @to_clean.pop
|
127
166
|
filename = @not_converted_files[key]
|
128
167
|
dirname = File.dirname(@not_converted_files[key])
|
129
|
-
puts %Q{mkdir -p "#{
|
130
|
-
else
|
131
|
-
|
168
|
+
puts %Q{mkdir -p "#{clean_dir}/#{dirname}" && mv "#{filename}" "#{clean_dir}/#{filename}"\n\n}
|
169
|
+
#else
|
170
|
+
# puts "No more files to clean. Hooray!"
|
132
171
|
end
|
133
172
|
end
|
134
173
|
|
135
174
|
def list_converted
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
175
|
+
begin
|
176
|
+
while @to_clean
|
177
|
+
key = @to_clean.pop
|
178
|
+
converted_filename = @converted_files[key]
|
179
|
+
old_filename = @not_converted_files[key]
|
180
|
+
dirname = File.dirname(@not_converted_files[key])
|
181
|
+
puts "\nConverted file:\n"
|
182
|
+
puts %Q{In Directory "#{dirname}"}
|
183
|
+
p `ls -lh "#{converted_filename}"`
|
184
|
+
p `ls -lh "#{old_filename}"`
|
185
|
+
puts %Q{To test run: open "#{converted_filename}"}
|
186
|
+
puts "\n\n"
|
187
|
+
end
|
188
|
+
rescue
|
189
|
+
puts("\nNothing to list")
|
149
190
|
end
|
150
191
|
end
|
151
192
|
|
152
|
-
|
153
193
|
option_parser.parse!
|
154
194
|
puts options.inspect
|
155
|
-
if options[:base_dir]
|
156
|
-
basedir = options[:base_dir]
|
157
|
-
get_all_files(basedir)
|
158
|
-
else
|
159
|
-
get_all_files
|
160
|
-
end
|
161
|
-
|
162
|
-
get_unconverted_files(@converted_files, @not_converted_files)
|
163
|
-
@to_clean = @not_converted_files.keys & @converted_files.keys
|
164
195
|
|
165
196
|
if options[:num_files]
|
166
197
|
limit = (options[:num_files] - 1).to_i
|
@@ -172,45 +203,46 @@ case
|
|
172
203
|
when options[:wack] == TRUE && options[:clean_up] == TRUE
|
173
204
|
puts("Error! -w (--wack) and -c (--clean-up) cannot be used simultaneously.")
|
174
205
|
when options[:list_converted] == TRUE
|
206
|
+
get_all_files(options)
|
207
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
208
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
175
209
|
list_converted
|
176
210
|
when options[:dry_run] == TRUE && options[:clean_up] == TRUE
|
211
|
+
get_all_files(options)
|
212
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
213
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
214
|
+
echo_base_dirs(options)
|
177
215
|
(0..limit).each do
|
178
|
-
dry_clean_up
|
216
|
+
dry_clean_up(options)
|
179
217
|
end
|
180
218
|
when options[:clean_up] == TRUE
|
219
|
+
get_all_files(options)
|
220
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
221
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
222
|
+
echo_base_dirs(options)
|
181
223
|
(0..limit).each do
|
182
|
-
puts "I would have run clean_up"
|
183
|
-
|
224
|
+
#puts "I would have run clean_up"
|
225
|
+
clean_up(options)
|
184
226
|
end
|
185
227
|
when options[:dry_run] == TRUE && options[:wack] == TRUE
|
228
|
+
get_all_files(options)
|
229
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
230
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
231
|
+
echo_base_dirs(options)
|
186
232
|
(0..limit).each do |i|
|
187
233
|
file = @to_convert[i]
|
188
234
|
dry_run(file)
|
189
235
|
end
|
190
236
|
when options[:wack] == TRUE
|
237
|
+
get_all_files(options)
|
238
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
239
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
240
|
+
echo_base_dirs(options)
|
191
241
|
(0..limit).each do |i|
|
192
242
|
file = @to_convert[i]
|
193
|
-
puts "I would have run convert(file)"
|
194
|
-
|
243
|
+
#puts "I would have run convert(file)"
|
244
|
+
convert(file)
|
195
245
|
end
|
196
246
|
else
|
197
247
|
puts help_text
|
198
248
|
end
|
199
|
-
|
200
|
-
=begin
|
201
|
-
(0..limit).each do |i|
|
202
|
-
file = @to_convert[i]
|
203
|
-
if options[:dry_run] == TRUE
|
204
|
-
|
205
|
-
else
|
206
|
-
if options[:clean_up] == TRUE
|
207
|
-
puts "I would have run clean_up"
|
208
|
-
#clean_up
|
209
|
-
else
|
210
|
-
puts "I would have run convert(file)"
|
211
|
-
#convert(file)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
=end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# bvwack - Bulk Convert video files
|
2
|
+
|
3
|
+
Author:: Robie Lutsey
|
4
|
+
|
5
|
+
Copyright:: Copyright (c) 2012 by Robie Lutsey
|
6
|
+
License:: Distributed under the Apache License
|
7
|
+
|
8
|
+
bvwack (sounds like bivouc) is a dead simple tool for converting logs of video files.
|
9
|
+
Currently it supports .avi and .mkv --> iPad compatible .mp4.
|
10
|
+
|
11
|
+
## Install
|
12
|
+
|
13
|
+
gem install bvwack
|
14
|
+
|
15
|
+
## Use
|
16
|
+
|
17
|
+
bvwack -[wc] < -n # -b base-dir >
|
18
|
+
|
19
|
+
For more help:
|
20
|
+
|
21
|
+
bvwack --help
|
22
|
+
|
23
|
+
## Developing for `bvwack`
|
24
|
+
|
25
|
+
TODO
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib/bvwack", __FILE__)
|
2
|
+
require "bvwack_version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "bvwack"
|
6
|
+
s.version = BVWack::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Robie Lutsey"]
|
9
|
+
s.email = ["robie 0x55D in dec at gmail dit com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{bvwack will wack it's way your pile of unconverted video files.'}
|
12
|
+
s.description = %q{Super simple utility to help you convert all your videos to iPad ready files.}
|
13
|
+
s.requirements = ['ffmpeg and a libx264-slow.ffpreset (possibly in your ~/.ffmpeg/ directory.) Google is your friend.']
|
14
|
+
s.rubyforge_project = "bvwack"
|
15
|
+
s.required_ruby_version = '>=1.9'
|
16
|
+
s.files = Dir['**/**']
|
17
|
+
s.executables = ["bvwack"]
|
18
|
+
s.has_rdoc = false
|
19
|
+
end
|
@@ -0,0 +1,252 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
DEFAULT_CONVERT_BASE_DIR = "#{ENV['PWD']}"
|
4
|
+
DEFAULT_CLEAN_BASE_DIR = "#{ENV['PWD']}/bvwack-back"
|
5
|
+
FFMPEG_OPTS = "-acodec aac -ac 2 -ab 160k -s 1024x768 -vcodec libx264 -vpre slow -vpre iPod640 -vb 1200k -f mp4 -threads 2 -strict experimental"
|
6
|
+
help_text = "
|
7
|
+
Usage: bvwack <options>
|
8
|
+
|
9
|
+
Default action is equivalent to bvwack -n 2
|
10
|
+
|
11
|
+
Options:
|
12
|
+
-b BASE_DIR, --base-dir BASE_DIR Set BASE_DIR instead of /Volumes/thundar/media/video
|
13
|
+
-d, --dry-run Do a dry run. Prints proposed commands to STDOUT.
|
14
|
+
-c, --clean-up Instead of converting, move all converted files to /Volumes/thundar/media/converted/[old-path]
|
15
|
+
-n #, --num-files # Number of videos to batch.
|
16
|
+
-l, --list_converted Lists files that have been converted but not cleaned. Useful for vierifying successful conversion.
|
17
|
+
|
18
|
+
Notes: By default this will not work for you. You must change DEFAULT_CONVERT_BASE_DIR
|
19
|
+
and DEFAULT_CLEAN_BASE_DIR to something that exists on your system. Do not let
|
20
|
+
the clean dir be a subdirectory of base dir or you'll be sad. I have set the
|
21
|
+
FFMPEG options to use only 2 threads. This allows me to use my laptop while
|
22
|
+
converting things. If you just want to hog through video try setting -threads 0
|
23
|
+
in FFMPEG_OPTS. Currently this only works on UNIX-like systems.
|
24
|
+
|
25
|
+
Requirements: ffmpeg and a libx264-slow.ffpreset (possibly in your ~/.ffmpeg/ directory or in your Cellar if you use brew.) Google is your friend.
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
bvwack -dw Shows proposed commands for 2 videos
|
29
|
+
bvwack -w -b somedir/anotherdir -n 5 Converts 5 videos under somedir/anotherdir
|
30
|
+
bvwack -c -n 10 Moves 10 already converted mkv or avi files to /Volumes/thundar/medai/converted/[od-path]"
|
31
|
+
|
32
|
+
@converted_files = { }
|
33
|
+
@not_converted_files = { }
|
34
|
+
@to_convert = []
|
35
|
+
|
36
|
+
|
37
|
+
options = { }
|
38
|
+
option_parser = OptionParser.new do |opts|
|
39
|
+
opts.on("-d", "--dry-run") do
|
40
|
+
options[:dry_run] = true
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("-b BASE_DIR", "--base-dir BASE_DIR") do |base_dir|
|
44
|
+
options[:base_dir] = base_dir
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on("-c", "--clean-up") do
|
48
|
+
options[:clean_up] = true
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on("-n NUM_FILES", "--num-files NUM_FILES", Integer) do |num_files|
|
52
|
+
options[:num_files] = num_files
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("-h", "--help") do
|
56
|
+
options[:help] = true
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("-l", "--list-converted") do
|
60
|
+
options[:list_converted] = true
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on("-w", "--wack") do
|
64
|
+
options[:wack] = true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def echo_base_dirs(options)
|
69
|
+
if options[:base_dir]
|
70
|
+
puts "\nOperating in #{ options[:base_dir]}"
|
71
|
+
puts "I will create #{ options[:base_dir]}/bvwack-back to store converted files if you use clean-up.\n\n"
|
72
|
+
else
|
73
|
+
puts "\nOperating in #{DEFAULT_CONVERT_BASE_DIR}"
|
74
|
+
puts "I will create #{ DEFAULT_CLEAN_BASE_DIR} to store converted files if you use clean-up.\n\n"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def convert(path_to_file)
|
79
|
+
if path_to_file.class == String
|
80
|
+
`ffmpeg -i "#{path_to_file}" #{FFMPEG_OPTS} "#{path_to_file.gsub(/mkv$|avi$/, "ipad.mp4")}"`
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def dry_run(path_to_file)
|
85
|
+
if path_to_file.class == String
|
86
|
+
puts "ffmpeg -i #{path_to_file} #{FFMPEG_OPTS} #{path_to_file.gsub(/mkv$|avi$/, "ipad.mp4")}\n\n"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def get_files(args)
|
92
|
+
if args[0]
|
93
|
+
args.each do |path|
|
94
|
+
if File.file?(path)
|
95
|
+
@paths << path
|
96
|
+
else
|
97
|
+
puts "#{path} is not a real file. Skipping. Try single-quoting the path if it is spacey or ugly."
|
98
|
+
end
|
99
|
+
end
|
100
|
+
else
|
101
|
+
puts "Specify the file(s) to convert: ./media/dir/dir/file1.mkv <'./media/dir/dir name/file(2).avi'>"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def get_all_files(options)
|
107
|
+
if options[:base_dir]
|
108
|
+
base_dir = options[:base_dir]
|
109
|
+
else
|
110
|
+
base_dir = DEFAULT_CONVERT_BASE_DIR
|
111
|
+
end
|
112
|
+
Dir.chdir(base_dir)
|
113
|
+
converted_files = Dir.glob(File.join("**", "*ipad.mp4"))
|
114
|
+
converted_files.each do |i|
|
115
|
+
if i.include?("bvwack-back")
|
116
|
+
next
|
117
|
+
else
|
118
|
+
@converted_files[File.basename(i, ".ipad.mp4")] = i
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
not_converted_files = Dir.glob(File.join("**", "*.{mkv,avi}"))
|
123
|
+
not_converted_files.each do |i|
|
124
|
+
if i.include?("bvwack-back")
|
125
|
+
next
|
126
|
+
else
|
127
|
+
if File.basename(i).split(".").last == "mkv"
|
128
|
+
@not_converted_files[File.basename(i, ".mkv")] = i
|
129
|
+
elsif File.basename(i).split(".").last == "avi"
|
130
|
+
@not_converted_files[File.basename(i, ".avi")] = i
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def get_unconverted_files(converted_files, not_converted_files)
|
137
|
+
(not_converted_files.keys - converted_files.keys).each do |key|
|
138
|
+
@to_convert << @not_converted_files[key]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def clean_up(options)
|
143
|
+
if options[:base_dir]
|
144
|
+
clean_dir = "#{options[:base_dir]}/bvwack-back"
|
145
|
+
else
|
146
|
+
clean_dir = DEFAULT_CONVERT_BASE_DIR
|
147
|
+
end
|
148
|
+
if @to_clean.length > 0
|
149
|
+
key = @to_clean.pop
|
150
|
+
filename = @not_converted_files[key]
|
151
|
+
dirname = File.dirname(@not_converted_files[key])
|
152
|
+
`mkdir -p "#{clean_dir}/#{dirname}" && mv "#{filename}" "#{clean_dir}/#{filename}"`
|
153
|
+
#else
|
154
|
+
# puts "No more files to clean. Hooray!"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def dry_clean_up(options)
|
159
|
+
if options[:base_dir]
|
160
|
+
clean_dir = "#{options[:base_dir]}/bvwack-back"
|
161
|
+
else
|
162
|
+
clean_dir = DEFAULT_CONVERT_BASE_DIR
|
163
|
+
end
|
164
|
+
if @to_clean.length > 0
|
165
|
+
key = @to_clean.pop
|
166
|
+
filename = @not_converted_files[key]
|
167
|
+
dirname = File.dirname(@not_converted_files[key])
|
168
|
+
print "\n\ndirname: "
|
169
|
+
p dirname
|
170
|
+
print "\n\nclean_dir: "
|
171
|
+
p clean_dir
|
172
|
+
puts %Q{mkdir -p "#{clean_dir}/#{dirname}" && mv "#{filename}" "#{clean_dir}/#{filename}"\n\n}
|
173
|
+
#else
|
174
|
+
# puts "No more files to clean. Hooray!"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def list_converted
|
179
|
+
begin
|
180
|
+
while @to_clean
|
181
|
+
key = @to_clean.pop
|
182
|
+
converted_filename = @converted_files[key]
|
183
|
+
old_filename = @not_converted_files[key]
|
184
|
+
dirname = File.dirname(@not_converted_files[key])
|
185
|
+
puts "\nConverted file:\n"
|
186
|
+
puts %Q{In Directory "#{dirname}"}
|
187
|
+
p `ls -lh "#{converted_filename}"`
|
188
|
+
p `ls -lh "#{old_filename}"`
|
189
|
+
puts %Q{To test run: open "#{converted_filename}"}
|
190
|
+
puts "\n\n"
|
191
|
+
end
|
192
|
+
rescue
|
193
|
+
puts("\nNothing to list")
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
option_parser.parse!
|
198
|
+
puts options.inspect
|
199
|
+
|
200
|
+
if options[:num_files]
|
201
|
+
limit = (options[:num_files] - 1).to_i
|
202
|
+
else
|
203
|
+
limit = 2
|
204
|
+
end
|
205
|
+
|
206
|
+
case
|
207
|
+
when options[:wack] == TRUE && options[:clean_up] == TRUE
|
208
|
+
puts("Error! -w (--wack) and -c (--clean-up) cannot be used simultaneously.")
|
209
|
+
when options[:list_converted] == TRUE
|
210
|
+
get_all_files(options)
|
211
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
212
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
213
|
+
list_converted
|
214
|
+
when options[:dry_run] == TRUE && options[:clean_up] == TRUE
|
215
|
+
get_all_files(options)
|
216
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
217
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
218
|
+
echo_base_dirs(options)
|
219
|
+
(0..limit).each do
|
220
|
+
dry_clean_up(options)
|
221
|
+
end
|
222
|
+
when options[:clean_up] == TRUE
|
223
|
+
get_all_files(options)
|
224
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
225
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
226
|
+
echo_base_dirs(options)
|
227
|
+
(0..limit).each do
|
228
|
+
#puts "I would have run clean_up"
|
229
|
+
clean_up(options)
|
230
|
+
end
|
231
|
+
when options[:dry_run] == TRUE && options[:wack] == TRUE
|
232
|
+
get_all_files(options)
|
233
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
234
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
235
|
+
echo_base_dirs(options)
|
236
|
+
(0..limit).each do |i|
|
237
|
+
file = @to_convert[i]
|
238
|
+
dry_run(file)
|
239
|
+
end
|
240
|
+
when options[:wack] == TRUE
|
241
|
+
get_all_files(options)
|
242
|
+
get_unconverted_files(@converted_files, @not_converted_files)
|
243
|
+
@to_clean = @not_converted_files.keys & @converted_files.keys
|
244
|
+
echo_base_dirs(options)
|
245
|
+
(0..limit).each do |i|
|
246
|
+
file = @to_convert[i]
|
247
|
+
#puts "I would have run convert(file)"
|
248
|
+
convert(file)
|
249
|
+
end
|
250
|
+
else
|
251
|
+
puts help_text
|
252
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "bvwack/convert"
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bvwack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -25,7 +25,16 @@ files:
|
|
25
25
|
- lib/bvwack/bvwack_version.rb
|
26
26
|
- lib/bvwack/convert.rb
|
27
27
|
- lib/bvwack.rb
|
28
|
+
- pkg/bvwack-0.0.2/bin/bvwack
|
29
|
+
- pkg/bvwack-0.0.2/bvwack.gemspec
|
30
|
+
- pkg/bvwack-0.0.2/lib/bvwack/bvwack_version.rb
|
31
|
+
- pkg/bvwack-0.0.2/lib/bvwack/convert.rb
|
32
|
+
- pkg/bvwack-0.0.2/lib/bvwack.rb
|
33
|
+
- pkg/bvwack-0.0.2/Rakefile
|
34
|
+
- pkg/bvwack-0.0.2/README.md
|
35
|
+
- pkg/bvwack-0.0.2.gem
|
28
36
|
- Rakefile
|
37
|
+
- README.md
|
29
38
|
homepage: ''
|
30
39
|
licenses: []
|
31
40
|
post_install_message:
|