Created
December 4, 2014 00:27
-
-
Save dallasmarlow/51d0dfed20eed3dc0053 to your computer and use it in GitHub Desktop.
today's duplicate imgs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
today = Time.now.yday | |
duplicate_files = [] | |
File.read('/opt/images.tsv').lines.reduce([]) do |files, entry| | |
size, filename = entry.chomp.split | |
if filename and not filename.empty? | |
files << [File.basename(filename), filename].join(':') | |
end | |
files | |
end.sort.reduce do |last_entry, entry| | |
basename, path = entry.split(':') | |
if last_entry | |
last_basename, last_path = last_entry.split(':') | |
if basename == last_basename | |
mtime = File.mtime(path) | |
if mtime.yday == today | |
[path, last_path].each do |p| | |
duplicate_files << p | |
end | |
end | |
end | |
end | |
last_entry = entry | |
end | |
duplicate_files.uniq.each do |file| | |
puts [file, File.mtime(file)].join("\t") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment