leran 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/leran +4 -5
- data/lib/leran.rb +16 -11
- metadata +2 -2
data/bin/leran
CHANGED
@@ -7,17 +7,16 @@ if ARGV[0] == "help" || ARGV[0] == nil
|
|
7
7
|
puts %q{Use demonstration:
|
8
8
|
leran fromDir toDir [-d]
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
isDeep => find for archives in fromDir subfolders. For yes, use -d
|
10
|
+
fromDir, the desorganized directory
|
11
|
+
toDir, the directory for to move the organized files
|
12
|
+
-d, find for archives in fromDir subfolders
|
14
13
|
|
15
14
|
Enjoy it!}
|
16
15
|
else
|
17
16
|
goNow = Leran.new ARGV[0],ARGV[1],ARGV[2]
|
18
17
|
|
19
18
|
puts "Organized files counter: #{goNow.totalMoveds}
|
20
|
-
Finished! \n -Script by
|
19
|
+
Finished! \n -Script by Gabriel Rubens
|
21
20
|
Press Enter to close..."
|
22
21
|
STDIN.readline
|
23
22
|
end
|
data/lib/leran.rb
CHANGED
@@ -27,19 +27,23 @@ class Leran
|
|
27
27
|
# def scanFolder: Find folders and files
|
28
28
|
# def moveFile: do... duhhhh
|
29
29
|
|
30
|
-
def initialize( fromDir, toDir, isDeep )
|
30
|
+
def initialize( fromDir, toDir, isDeep, regexp )
|
31
31
|
@qtMoveds = 0
|
32
32
|
toDir = fromDir if toDir == '-e'
|
33
33
|
|
34
|
-
puts '_' *
|
34
|
+
puts '_' * 52
|
35
35
|
puts 'Entering in the store directory and creating folders'
|
36
|
+
puts '_' * 52
|
36
37
|
|
37
|
-
scanFolder fromDir,toDir,isDeep
|
38
|
+
scanFolder fromDir, toDir, isDeep, regexp
|
38
39
|
end
|
39
40
|
|
40
|
-
def scanFolder( from,to,deep )
|
41
|
+
def scanFolder( from,to,deep, regexp )
|
41
42
|
Dir.foreach( from ) do |file|
|
42
|
-
if !File.directory? "#{from}/#{file}"
|
43
|
+
if !File.directory? "#{from}/#{file}"
|
44
|
+
if regexp
|
45
|
+
FileUtils::mv("#{from}/#{file}", "#{to}/#{byREGEXP}/#{file}")
|
46
|
+
end
|
43
47
|
ext = File.extname( file ).upcase
|
44
48
|
|
45
49
|
moveFile from,to,file,ext if ext != ""
|
@@ -52,15 +56,16 @@ class Leran
|
|
52
56
|
def moveFile( from,to,file,ext )
|
53
57
|
@@fileTypes.each_key do | type |
|
54
58
|
if @@fileTypes[type].include? ext
|
55
|
-
puts "
|
59
|
+
puts "\tMoving: #{file.slice(0,20)}... | Type: #{type}"
|
56
60
|
|
57
61
|
# First: Create the folder for type
|
58
62
|
# Second: Create the folder for extension
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
FileUtils
|
63
|
+
|
64
|
+
FileUtils::mkdir_p( "#{to}/#{type}" ) if !File.exists? "#{to}/#{type}"
|
65
|
+
FileUtils::mkdir_p( "#{to}/#{type}/F#{ext}" ) if !File.exists? "#{to}/#{type}/F#{ext}"
|
66
|
+
|
67
|
+
FileUtils::mv "#{from}/#{file}", "#{to}/#{type}/F#{ext}"
|
68
|
+
|
64
69
|
@qtMoveds += 1
|
65
70
|
end
|
66
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leran
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,5 +43,5 @@ rubyforge_project:
|
|
43
43
|
rubygems_version: 1.8.24
|
44
44
|
signing_key:
|
45
45
|
specification_version: 3
|
46
|
-
summary:
|
46
|
+
summary: It's organize time
|
47
47
|
test_files: []
|