right_data 0.5.16 → 0.5.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/main.rb +12 -1
  2. data/lib/right_data.rb +12 -1
  3. metadata +3 -3
data/lib/main.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'FileSystemItem'
3
+ require 'escape'
3
4
  # require 'unicode'
4
5
 
5
6
  $KCODE = 'UTF-8' # only used when encoding is not specified.
@@ -104,7 +105,7 @@ module RightData
104
105
  count = 0
105
106
  Find.find(*paths) { |f|
106
107
  sizes[File.size(f)] << f if File.file?(f) && !ignore_test(f)
107
- count += 1
108
+ count += 1
108
109
  }
109
110
  puts "# Indexed #{count} files."
110
111
  sizes
@@ -187,6 +188,16 @@ module RightData
187
188
  master = "/Users/jonathan/Dropbox"
188
189
  prune = "/Users/jonathan/Desktop/Old"
189
190
  scan_for_prunable(master,prune) { |a,b| puts "#{b.size} : #{a}" }
191
+ # each_set_of_duplicates(prune)
192
+ end
193
+
194
+ def self.scan_for_dup(prunable)
195
+ each_set_of_duplicates(prune) do |dups|
196
+ puts "# #{Escape.shell_command(dups.shift)}"
197
+ dups.each do |d|
198
+ puts Escape.shell_command(["rm","-rf",d," # dup"])
199
+ end
200
+ end
190
201
  end
191
202
 
192
203
  # tree = scan_for_prunable(master,prune) { |a,b| puts "#{b.size} : #{a}" }; nil
data/lib/right_data.rb CHANGED
@@ -6,6 +6,17 @@ module RightData
6
6
  tree = RightData::scan_for_prunable(master,prunable)
7
7
  tree.report('rm -rf'); nil
8
8
  end
9
+
10
+ def self.dup_report(prunable)
11
+ RightData::scan_for_dup(prune)
12
+ end
9
13
  end
10
14
  # Usage:
11
- # echo "gem 'right_data'; require 'right_data'; prune_report(master,prunable)" | ruby -rrubygems
15
+ # Prune any files from prunable that are already in master:
16
+ # echo "gem 'right_data'; require 'right_data'; prune_report(master,prunable)" | ruby -rrubygems > rm_report
17
+ # Inspect / add #!/bin/sh
18
+ # chmod +x rm_report
19
+ # ./rm_report
20
+ #
21
+ # Find duplicates:
22
+ # echo "gem 'right_data'; require 'right_data'; dup_report(runable)" | ruby -rrubygems > rm_report
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_data
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 41
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 16
10
- version: 0.5.16
9
+ - 17
10
+ version: 0.5.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan Siegel