Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
Forked from anonymous/cmp.rb
Created October 31, 2013 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyuki0000/7245245 to your computer and use it in GitHub Desktop.
Save hyuki0000/7245245 to your computer and use it in GitHub Desktop.
(まちがってanonymousで作ったので自分でfork) BOOKSCANでスキャンしたPDFを全部ダウンロードしたかどうかを確認するためのスクリプト。Webページから(手動で)スクレイプした書名一覧をbookscan.txtに入れて末尾の.pdfを消す。自分のダウンロードしたファイル一覧をdropbox.txtに入れて末尾の.pdfを消す。そしてこのスクリプトを動かす。要するにファイル名中に入っているISBNを比較してるだけ。一回しか使わなかったからインタフェース適当。
bookscan = Hash.new
dropbox = Hash.new
File::open("bookscan.txt") do |f|
f.each do |line|
line.match(/_([\dX]+)$/)
bookscan[$1] = line
end
end
File::open("dropbox.txt") do |f|
f.each do |line|
line.match(/_([\dX]+)$/)
dropbox[$1] = line
end
end
bookscan.keys.each do |line|
if not dropbox[line]
puts "#{bookscan[line]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment