Skip to content

Instantly share code, notes, and snippets.

@jubishop
Created March 29, 2024 16:23
Show Gist options
  • Save jubishop/f197bbfa385aa4d9447560dc66325cde to your computer and use it in GitHub Desktop.
Save jubishop/f197bbfa385aa4d9447560dc66325cde to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'set'
files = Dir.glob('**/*.ARW') + Dir.glob('**/*.RAF')
files.each { |old_file|
new_file = "#{File.join(File.dirname(old_file), File.basename(old_file, File.extname(old_file)))}.heic"
if File.exist?(new_file)
puts "Deleting #{old_file}"
File.delete(old_file)
else
puts `sips -s format heic "#{old_file}" -s formatOptions best --out "#{new_file}"`
end
}
puts "All existing extensions:"
files = Dir.glob('**/*').filter { |path| File.file?(path) }
extnames = Set.new
files.each { |file|
extnames.add(File.extname(file))
}
puts extnames.to_a.join(",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment