roto 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roto.rb +15 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1ed585bb9a71a90f338f0fcfc619ce256ed156c
|
4
|
+
data.tar.gz: 7b81afcba54013ea31c010d02550999547b47bbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ff79fac9dcc45b3d2b035b1c5cec201c3717aa73b6c4868e0f71b0c009056f404f203be0ea6475c33c342f60944f02179b5b78672cc632e0ab4476151e699e1
|
7
|
+
data.tar.gz: 3a8116768df2b6a175804fc39b9001831bc4ed4bd5c300ec56fe4c2103cf7844850ab86853ecd3464d2760b78a32da7f868ae5ad53f68b6acb097b36b42e306c
|
data/lib/roto.rb
CHANGED
@@ -3,12 +3,13 @@ require 'find'
|
|
3
3
|
require 'ruby-progressbar'
|
4
4
|
|
5
5
|
class Roto
|
6
|
-
attr_accessor :types, :files
|
6
|
+
attr_accessor :types, :files, :rename_files
|
7
7
|
attr_reader :files
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@files = []
|
11
|
-
@types = ['.mp4', '.mov', '.jpg', '.png']
|
11
|
+
@types = ['.mp4', '.mov', '.jpg', '.png', '.mts']
|
12
|
+
@rename_duplicatees = true
|
12
13
|
@errors = {}
|
13
14
|
end
|
14
15
|
|
@@ -26,7 +27,12 @@ class Roto
|
|
26
27
|
progressbar = ProgressBar.create(total: @files.count, format: '%w')
|
27
28
|
@files.each do |file|
|
28
29
|
begin
|
29
|
-
|
30
|
+
if @rename_duplicatees
|
31
|
+
ext = File.ext(file); name = File.basename(file, ext)
|
32
|
+
FileUtils.mv("#{file}", "#{destination}/#{name}_#{Time.now.to_i}#{ext}")
|
33
|
+
else
|
34
|
+
FileUtils.mv("#{file}", "#{destination}")
|
35
|
+
end
|
30
36
|
progressbar.increment
|
31
37
|
rescue => error
|
32
38
|
@errors[file] = error
|
@@ -38,7 +44,12 @@ class Roto
|
|
38
44
|
progressbar = ProgressBar.create(total: @files.count, format: '%w')
|
39
45
|
@files.each do |file|
|
40
46
|
begin
|
41
|
-
|
47
|
+
if @rename_duplicatees
|
48
|
+
ext = File.ext(file); name = File.basename(file, ext)
|
49
|
+
FileUtils.cp("#{file}", "#{destination}/#{name}_#{Time.now.to_i}#{ext}")
|
50
|
+
else
|
51
|
+
FileUtils.cp("#{file}", "#{destination}")
|
52
|
+
end
|
42
53
|
progressbar.increment
|
43
54
|
rescue => error
|
44
55
|
@errors[file] = error
|