Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created December 4, 2014 00:27
Show Gist options
  • Save dallasmarlow/51d0dfed20eed3dc0053 to your computer and use it in GitHub Desktop.
Save dallasmarlow/51d0dfed20eed3dc0053 to your computer and use it in GitHub Desktop.
today's duplicate imgs
#!/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