Skip to content

Instantly share code, notes, and snippets.

@c0ze
Created June 30, 2015 06:49
Show Gist options
  • Save c0ze/a21e98018299b51b275c to your computer and use it in GitHub Desktop.
Save c0ze/a21e98018299b51b275c to your computer and use it in GitHub Desktop.
A gist to unzip photos packed by google takeout and put them into folders by date
require 'zip'
file_path = ARGV[0]
Zip::ZipFile.open(file_path) { |zip_file|
zip_file.each { |f|
date = f.name.split("/")[2].split(" ")[0]
name = f.name.split("/")[3]
p "date #{date} name #{name}"
f_path=File.join("GooglePhotos", date.split("-"), name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.extract(f, f_path) unless File.exist?(f_path)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment