roto 0.1.4 → 0.1.5
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 +9 -5
- 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: 8e5c7f52512df7d0caf52c2db8f584ecea8b9d42
|
4
|
+
data.tar.gz: 50e33784de3d469a76badf0507583437d7027df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c94b7f62a1ec90d9ca96f0862264b9ca7807ec29dfe4e64209f2cc2745057d533dcbc209f66ccc4ee3dd508229af2ff8c4d5232dc3d44672939ccf666955c31
|
7
|
+
data.tar.gz: 87101c1d5036dff597bf44b2a8b61172d8e6a73c914da1906248affbc13c8653a85d69d360650226a7ae2d6c6980c379d11eae639161939aab402b77b76e9ded
|
data/lib/roto.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ruby-progressbar'
|
|
4
4
|
|
5
5
|
class Roto
|
6
6
|
attr_accessor :types, :files, :rename_files
|
7
|
-
attr_reader :files
|
7
|
+
attr_reader :files, :errors
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@files = []
|
@@ -26,9 +26,11 @@ class Roto
|
|
26
26
|
def move_files(destination)
|
27
27
|
progressbar = ProgressBar.create(total: @files.count, format: '%w')
|
28
28
|
@files.each do |file|
|
29
|
+
filename = File.basename(file)
|
30
|
+
ext = File.extname(file)
|
31
|
+
name = File.basename(file, ext)
|
29
32
|
begin
|
30
|
-
if @rename_duplicates
|
31
|
-
ext = File.extname(file); name = File.basename(file, ext)
|
33
|
+
if File.exist?("#{destination}/#{filename}") && @rename_duplicates
|
32
34
|
FileUtils.mv("#{file}", "#{destination}/#{name}_#{Time.now.to_i}#{ext}")
|
33
35
|
else
|
34
36
|
FileUtils.mv("#{file}", "#{destination}")
|
@@ -43,9 +45,11 @@ class Roto
|
|
43
45
|
def copy_files(destination)
|
44
46
|
progressbar = ProgressBar.create(total: @files.count, format: '%w')
|
45
47
|
@files.each do |file|
|
48
|
+
filename = File.basename(file)
|
49
|
+
ext = File.extname(file)
|
50
|
+
name = File.basename(file, ext)
|
46
51
|
begin
|
47
|
-
if @rename_duplicates
|
48
|
-
ext = File.extname(file); name = File.basename(file, ext)
|
52
|
+
if File.exist?("#{destination}/#{filename}") && @rename_duplicates
|
49
53
|
FileUtils.cp("#{file}", "#{destination}/#{name}_#{Time.now.to_i}#{ext}")
|
50
54
|
else
|
51
55
|
FileUtils.cp("#{file}", "#{destination}")
|