Skip to content

Instantly share code, notes, and snippets.

@vernalkick
Last active September 30, 2021 20:20
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vernalkick/3f7aad667e961953f3e415d08dd1dfe4 to your computer and use it in GitHub Desktop.
Save vernalkick/3f7aad667e961953f3e415d08dd1dfe4 to your computer and use it in GitHub Desktop.
Ember Exporter
#!/usr/bin/env ruby
# Input arguments
source_path = ARGV[0]
destinationPath = ARGV[1] || '~/Desktop/ember_backup'
# Creade destination directory if it doesn't exist
`mkdir -p #{destinationPath}`
# Find the embersnaps in the directory and count them
ember_snaps = Dir["#{source_path}/*.embersnap"]
ember_snaps_count = ember_snaps.count
number_of_files_successfully_copied = 0
files_not_copied = []
# Loop through the snaps, find the media file and copy it to the destination
ember_snaps.each_with_index do |file, index|
image_file = Dir["#{file}/*.{png,PNG,jpg,JPG,jpeg,psd,gif,mov,svg}"][0]
if image_file == nil
files_not_copied << file
next
end
print "Copying file #{index + 1}/#{ember_snaps_count}...\r"
`cp '#{image_file}' #{destinationPath}`
number_of_files_successfully_copied += 1
end
# Let the user know it's done!
puts "Done! #{number_of_files_successfully_copied} of #{ember_snaps_count} files copied."
# If there's been any errors, let the user know
if number_of_files_successfully_copied > 0
puts "\n#{files_not_copied.count} file#{'s' if files_not_copied.count > 1} could not be copied:"
files_not_copied.each do |file|
puts "- #{file}"
end
end
@vernalkick
Copy link
Author

vernalkick commented Feb 27, 2018

For the past few years I've been collecting design inspiration in Ember. Sadly, Realmac has stopped development of Ember without giving users a good way to export their Library from High Sierra where the app just crashes on launch. Thankfully, the folder structure of the Ember library is pretty straightforward and contains all of the original image files.

This script automates the process of exporting your library so you don't have to copy each file manually.

How it works

$ ruby ember_exporter.rb [ember_library_snaps_folder_path] [target_directory_path] (optional)

Here's an example of how it works in practice:

$ ruby ember_exporter.rb "~/Dropbox (Personal)/Apps/EmberApp/EmberLibrary/Snaps"

If you don't include a target path (as you see above), your images will be copied to a ember_backup folder on your desktop.

@squill
Copy link

squill commented Jun 16, 2018

I copied one of the .embersnap files, changed the format to .jpg, opened the folder and I can see the jpg.

Not sure what your script does. Is it the equivalent of doing what I just did, but as a batch processor?

@mavrck
Copy link

mavrck commented Aug 11, 2018

Super helpful! Thanks.

@nmercado
Copy link

Thanks to your script I could save a library that I had been saving for a decade! thank you!

@casekhor
Copy link

casekhor commented Dec 5, 2018

Thanks for this

@gavinplatt
Copy link

Thank you very much for this, finally restored a huge library which I thought was lost.

@ViktorVR
Copy link

Hi Vernalkick, after a long odyssey of looking for an alternative to ember I've found Eagle which works very similar to Ember. Yet, transfering the library from Ember to Eagle is manually impossible. Do you think it's possible to write a script, that copies all metadata like tags, notes and URLs to IPTC tags which the could be imported to Eagle...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment