我从https://gist.github.com/mattdipasquale/571405
分出了这个要点我收到以下错误:
deDUPER.rb:14:in `read': Invalid argument - /Volumes/Drobo #1 2009-2012/AMNH Video/2012/2012-01-17 Creatures of Light/Capture Scratch/Art 3:9/Capture Scratch/2012-03-09_microraptor livestream/A Cam_Microraptor livestream.mov (Errno::EINVAL)
from deDUPER.rb:14:in `block in <main>'
from deDUPER.rb:10:in `each'
from deDUPER.rb:10:in `<main>'
我认为这是由文件或文件夹名称中的非法字符引起的,但我不确定。我不想更改文件或文件夹名称,因为它们链接到旧的Final Cut Pro项目文件,这些文件依赖于引用的文件路径来保持项目的完整性。有任何人对此有经验吗?有没有办法让这个脚本工作而不必更改文件或文件夹名称?
# Define the unique method that removes duplicates
#!/usr/bin/ruby
require 'digest/md5'
library_path = ARGV[0]
hash = {}
Dir.glob(library_path + "/**/*", File::FNM_DOTMATCH).each do |filename|
next if File.directory?(filename)
puts 'Checking ' + filename
key = Digest::MD5.hexdigest(IO.read(filename)).to_sym
if hash.has_key? key
# puts "same file #{filename}"
hash[key].push filename
else
hash[key] = [filename]
end
end
hash.each_value do |filename_array|
if filename_array.length > 1
puts "=== Identical Files ===\n"
filename_array.each { |filename| puts ' '+filename }
end
end