Skip to content

Instantly share code, notes, and snippets.

@matsu911
Created September 18, 2013 13:25
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 matsu911/6609106 to your computer and use it in GitHub Desktop.
Save matsu911/6609106 to your computer and use it in GitHub Desktop.
require 'digest/sha1'
require 'sqlite3'
def sha1(s)
Digest::SHA1.hexdigest(s)
end
backup_dir = '1b345454cbec76848e94c41ce0a2d6b7328973e9'
backup_path = "#{ENV['HOME']}/Library/Application Support/MobileSync/Backup/#{backup_dir}"
domain = "CameraRollDomain"
file = "Media/PhotoData/Photos.sqlite"
hash = sha1 "#{domain}-#{file}"
db = SQLite3::Database.new "#{backup_path}/#{hash}"
db.execute("select zdirectory, ZFILENAME from zgenericasset").each do |row|
puts row[1]
hash = sha1 "#{domain}-Media/#{row.join('/')}"
system "cp '#{backup_path}/#{hash}' media/#{row[1]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment