Skip to content

Instantly share code, notes, and snippets.

@rockpapergoat
rockpapergoat / get_app_version.rb
Created February 24, 2011 14:52
accepts an array as arguments on the command line or will loop through /Applications
#!/usr/bin/env ruby -wKU
# 110224, revised with loop to accept an array
def get_version(apps)
apps.each do |app|
if File.exists?("#{app}/Contents/Info.plist")
vers = `/usr/bin/defaults read "#{app}"/Contents/Info CFBundleShortVersionString`.chomp
puts "#{app.sub(/\/Applications\//, '')}: #{vers}"
$?.success? ? vers : "ERROR: could not get version"