event_splittr 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/bin/splittr +41 -0
- data/event_splittr.gemspec +24 -0
- data/lib/event_splittr/photo.rb +26 -0
- data/lib/event_splittr/photo_collection.rb +25 -0
- data/lib/event_splittr/version.rb +3 -0
- data/lib/event_splittr.rb +5 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 406c93ad76d754e300fc8f0b5669bf0ce7d6722a
|
4
|
+
data.tar.gz: 8b75b0990ae13eab32df4654d1c4eedc0427b55f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de9a65f368b738528fe71b9f89b73bdfca93553ef70a5061a7e71756310e13b7dd4be78cf8146a19aec61a0790ee5b6f40da2081400afd0d71b76f3591db87c5
|
7
|
+
data.tar.gz: 2fc118bf52cb03a9b2f6a8dfdbc070febfeea0ea716ee8f8b58ed934a5d83cad9e6ad6ee9b66e9e176d3a3fc7d5ee999adc658b4019b6b65cf816425c36b34a5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Timothy Andrew
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# EventSplittr
|
2
|
+
|
3
|
+
Place a number of images in folders based on the date they were taken.
|
4
|
+
This is useful if you're using simple photo management tools like [Unbound][unbound] and you need to place images in folders based on the day they were taken.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```bash
|
9
|
+
$ gem install event_splittr
|
10
|
+
```
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
##### Perform a dry-run
|
15
|
+
|
16
|
+
```bash
|
17
|
+
$ splittr -d /destination_dir path/to/images/*jpg
|
18
|
+
```
|
19
|
+
|
20
|
+
This will output a list of things that will be moved.
|
21
|
+
|
22
|
+
##### Move files
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ splittr -f -d /destination_dir path/to/images/*jpg
|
26
|
+
```
|
27
|
+
|
28
|
+
This will create sub-folders in destination_dir with a format like "2014-05-06", and put all the images taken on that day in that folder.
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( http://github.com/<my-github-username>/event_splittr/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
37
|
+
|
38
|
+
[unbound]: http://unboundformac.com/
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/splittr
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib/event_splittr")
|
4
|
+
|
5
|
+
require 'photo_collection'
|
6
|
+
require 'photo'
|
7
|
+
require 'optparse'
|
8
|
+
|
9
|
+
|
10
|
+
options = {}
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: splittr [[jpg image paths]"
|
13
|
+
|
14
|
+
opts.on("-f", "Actually move files to the destination. Will only perform a dry run if this option is not passed.") do |f|
|
15
|
+
options[:force] = f
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on("-dDESTINATION", "--destination=DESTINATION", "Destination directory.") do |d|
|
19
|
+
options[:destination] = d
|
20
|
+
end
|
21
|
+
end.parse!
|
22
|
+
|
23
|
+
if not File.exists?(options[:destination].to_s)
|
24
|
+
puts "-> A valid destination directiory is required."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
photos = EventSplittr::PhotoCollection.new(ARGV)
|
31
|
+
|
32
|
+
if options[:force]
|
33
|
+
puts "-> Moving files to #{options[:destination]}"
|
34
|
+
photos.split(options[:destination])
|
35
|
+
else
|
36
|
+
puts "-> Performing dry run"
|
37
|
+
photos.split_dry_run(options[:destination])
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'event_splittr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "event_splittr"
|
8
|
+
spec.version = EventSplittr::VERSION
|
9
|
+
spec.authors = ["Timothy Andrew"]
|
10
|
+
spec.email = ["mail@timothyandrew.net"]
|
11
|
+
spec.summary = "Split photos into events by date."
|
12
|
+
spec.description = %q{Write a longer description. Optional.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "exifr", "~> 1.1.3"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'exifr'
|
2
|
+
|
3
|
+
module EventSplittr
|
4
|
+
class Photo
|
5
|
+
attr_reader :path
|
6
|
+
|
7
|
+
def initialize(path)
|
8
|
+
@photo = EXIFR::JPEG.new(path)
|
9
|
+
@path = path
|
10
|
+
end
|
11
|
+
|
12
|
+
def destination_path(destination_dir)
|
13
|
+
"#{destination_dir}/#{project_name}/#{Pathname.new(path).basename}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def project_name
|
17
|
+
time_taken.strftime("%Y-%m-%d")
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def time_taken
|
23
|
+
@photo.date_time
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module EventSplittr
|
5
|
+
class PhotoCollection
|
6
|
+
def initialize(paths)
|
7
|
+
@photos = paths.select {|path| File.extname(path).downcase == ".jpg"}.map {|path| Photo.new(path)}
|
8
|
+
end
|
9
|
+
|
10
|
+
def split(destination_dir)
|
11
|
+
@photos.each do |photo|
|
12
|
+
FileUtils.mkdir_p("#{destination_dir}/#{photo.project_name}")
|
13
|
+
FileUtils.mv(photo.path, photo.destination_path(destination_dir))
|
14
|
+
puts "Moved: #{photo.path} to #{photo.destination_path(destination_dir)}"
|
15
|
+
end
|
16
|
+
puts "-> Moved #{@photos.size} photos."
|
17
|
+
end
|
18
|
+
|
19
|
+
def split_dry_run(destination_dir)
|
20
|
+
@photos.each do |photo|
|
21
|
+
puts "Will move: #{photo.path} to #{photo.destination_path(destination_dir)}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: event_splittr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Timothy Andrew
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: exifr
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Write a longer description. Optional.
|
56
|
+
email:
|
57
|
+
- mail@timothyandrew.net
|
58
|
+
executables:
|
59
|
+
- splittr
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/splittr
|
69
|
+
- event_splittr.gemspec
|
70
|
+
- lib/event_splittr.rb
|
71
|
+
- lib/event_splittr/photo.rb
|
72
|
+
- lib/event_splittr/photo_collection.rb
|
73
|
+
- lib/event_splittr/version.rb
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Split photos into events by date.
|
98
|
+
test_files: []
|
99
|
+
has_rdoc:
|