photo_rename 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.org +20 -1
- data/bin/photo_rename +1 -1
- data/lib/photo_rename.rb +16 -8
- data/lib/photo_rename/version.rb +1 -1
- data/photo_rename.gemspec +4 -2
- data/screenshots/example.png +0 -0
- data/screenshots/install.png +0 -0
- metadata +20 -5
- data/screenshots/2014-07-05-135037_818x747_scrot.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ec86080ae15389f539c47aafc0f780d795319c7
|
4
|
+
data.tar.gz: 03d2696d36dcb5090c4fea24246d2a1a7d8d5a63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1543cfc677fa16d43663658a5da164e280ab69f29c5e51f5e9c22d93f9111469546df1841d2d660df6efa104560cd10c69e05cc8796a015c14587e78e29cdb
|
7
|
+
data.tar.gz: 3d14851a6b3fa6f2fe52d73dc9d2de3c9e199268edbe2eca1e8daa155c80bb2a7dfd8f55682ab19078773fec012a79c27f06a3a12ca98e72f3d82d37186eed61
|
data/Gemfile
CHANGED
data/README.org
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
* Photo Renamer
|
2
|
+
|
2
3
|
** What the script does
|
3
4
|
This script is fairly specific. It renames all JPG files (technically files with a .jpg or .jpeg extenstion) in a given directory to the form IMG_*yyyymmdd*_*hhmmss*.jpg
|
4
5
|
|
@@ -12,8 +13,26 @@ After some experimenting I found that if I copy photos from my camera's memory c
|
|
12
13
|
*IMPORTANT NOTE*
|
13
14
|
Since I am renaming files based on the date created by the device that captured the image, this device's date should be correctly set. (For the next release I want to add more options to manually set the date)
|
14
15
|
|
16
|
+
** Install
|
17
|
+
The easiest way to install the script is by using rubygems.
|
18
|
+
#+begin_src bash
|
19
|
+
gem install photo_rename
|
20
|
+
#+end_src
|
21
|
+
|
22
|
+
[[./screenshots/install.png]]
|
23
|
+
|
15
24
|
** Usage
|
16
|
-
|
25
|
+
#+begin_src bash
|
26
|
+
photo_rename photo_directory
|
27
|
+
#+end_src
|
28
|
+
|
29
|
+
[[./screenshots/example.png]]
|
30
|
+
** Release notes
|
31
|
+
*** 0.0.4
|
32
|
+
- Do not rename files that are already in the correct format.
|
33
|
+
|
34
|
+
*** 0.0.1 - 0.0.3
|
35
|
+
- Sort out teething problems with gem.
|
17
36
|
|
18
37
|
** GNU GPL
|
19
38
|
This program is licensed under [(http://www.gnu.org/licenses/gpl-3.0.txt)[GNU GPL]]
|
data/bin/photo_rename
CHANGED
@@ -5,7 +5,7 @@ require 'photo_rename'
|
|
5
5
|
def main()
|
6
6
|
photo_rename = Photo_rename.new()
|
7
7
|
ARGV.length == 0 ? print_opts = true : print_opts = false
|
8
|
-
|
8
|
+
photo_rename.parse_options(print_opts)
|
9
9
|
|
10
10
|
ARGV.each do |arg|
|
11
11
|
map = photo_rename.name_map(arg)
|
data/lib/photo_rename.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
|
19
19
|
require 'optparse'
|
20
|
-
require
|
20
|
+
require 'rubygems'
|
21
21
|
require 'awesome_print'
|
22
22
|
|
23
23
|
class Photo_rename
|
@@ -30,20 +30,28 @@ class Photo_rename
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def name_map(dir_path)
|
33
|
-
|
33
|
+
no_change_array = []
|
34
|
+
change_map = {}
|
34
35
|
Dir.glob("#{dir_path}/*.[jJ][pP][gG]").sort.each do |f|
|
35
|
-
|
36
|
-
|
36
|
+
if /[Ii][Mm][Gg]\_[0-9]{8}\_[0-9]{6}\.[Jj][Pp][Gg]/.match(f) == nil
|
37
|
+
mdate = File.mtime(f)
|
38
|
+
change_map[f] = "#{dir_path}/#{new_name(mdate)}"
|
39
|
+
else
|
40
|
+
no_change_array.push(f)
|
41
|
+
end
|
37
42
|
end
|
38
|
-
return
|
43
|
+
return [no_change_array, change_map]
|
39
44
|
end
|
40
45
|
|
41
46
|
def print_replace_names(dir_path, map)
|
42
|
-
puts "
|
43
|
-
ap map
|
47
|
+
puts "These files are in the correct format and will remain unchanged:"
|
48
|
+
ap map[0], :index => false
|
49
|
+
puts ""
|
50
|
+
puts "These files will be renamed as follows:"
|
51
|
+
ap map[1]
|
44
52
|
puts "Are you sure you want to continue renaming these files (Y/N)"
|
45
53
|
if STDIN.gets.chomp.downcase == "y"
|
46
|
-
map.each() do |key, value|
|
54
|
+
map[1].each() do |key, value|
|
47
55
|
File.rename("#{key}", "#{value}")
|
48
56
|
end
|
49
57
|
end
|
data/lib/photo_rename/version.rb
CHANGED
data/photo_rename.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["github@tjaart.co.za"]
|
11
11
|
spec.summary = "Photo renamer"
|
12
12
|
spec.description = "Rename JPG images in a directory based on the date in the file's mtime field. By default the target file names are in the same format as those created by Android devices."
|
13
|
-
spec.homepage ='https://github.com/tjaartvdwalt/
|
13
|
+
spec.homepage ='https://github.com/tjaartvdwalt/photo_rename'
|
14
14
|
spec.license = "GNU GPL"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -19,7 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
-
|
22
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
23
23
|
|
24
24
|
spec.add_runtime_dependency "awesome_print" , "~> 1.2"
|
25
|
+
|
26
|
+
spec.required_ruby_version = '~> 2.0'
|
25
27
|
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photo_rename
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tjaart van der Walt
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: awesome_print
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,8 +71,9 @@ files:
|
|
57
71
|
- lib/photo_rename.rb
|
58
72
|
- lib/photo_rename/version.rb
|
59
73
|
- photo_rename.gemspec
|
60
|
-
- screenshots/
|
61
|
-
|
74
|
+
- screenshots/example.png
|
75
|
+
- screenshots/install.png
|
76
|
+
homepage: https://github.com/tjaartvdwalt/photo_rename
|
62
77
|
licenses:
|
63
78
|
- GNU GPL
|
64
79
|
metadata: {}
|
@@ -68,9 +83,9 @@ require_paths:
|
|
68
83
|
- lib
|
69
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
85
|
requirements:
|
71
|
-
- - "
|
86
|
+
- - "~>"
|
72
87
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0'
|
88
|
+
version: '2.0'
|
74
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
90
|
requirements:
|
76
91
|
- - ">="
|
Binary file
|