Skip to content

Instantly share code, notes, and snippets.

@matiaskorhonen
Created January 6, 2018 12:42
Show Gist options
  • Save matiaskorhonen/1c5f6b814ffdfb1636f35c952c8e4631 to your computer and use it in GitHub Desktop.
Save matiaskorhonen/1c5f6b814ffdfb1636f35c952c8e4631 to your computer and use it in GitHub Desktop.
Small script to rename iOS app icons
require "fileutils"
require "json"
json = File.open("Contents.json", "r+")
contents = JSON.load(json.read)
contents["images"].map do |image|
ext = File.extname(image["filename"])
new_filename = "#{image["size"]}@#{image["scale"]}#{ext}"
FileUtils.mv(image["filename"], new_filename)
image["filename"].replace(new_filename)
end
json.rewind
json.write(JSON.pretty_generate(contents))
json.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment