« Microsoft Teams (work or school)バージョンチェッカー | トップページ | [BASH]NTP設定 »

CFBundleNameの取得


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

set strBaseURL to "https://app.jamfnow.com/applications/add/search/"

###################################
#####入力ダイアログ
###################################
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAppDirPathURLArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidAppDirPathURL to ocidAppDirPathURLArray's firstObject()
set aliasDefaultLocation to (ocidAppDirPathURL's absoluteURL()) as alias
set listUTI to {"com.apple.application-bundle"}
set strPromptText to "アプリケーションを選んでください" as text
set strMesText to "アプリケーションを選んでください" as text

set listAliasFilePath to (choose file strMesText with prompt strPromptText default location (aliasDefaultLocation) of type listUTI with invisibles and multiple selections allowed without showing package contents) as list

repeat with itemFilePath in listAliasFilePath
  set aliasFilePath to itemFilePath as alias
  set strFilePath to (POSIX path of aliasFilePath) as text
  set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:true)
  set ocidPlistPathURL to (ocidFilePathURL's URLByAppendingPathComponent:("Contents/Info.plist"))
  ####
  set listReadPlistData to (refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidPlistPathURL) |error|:(reference))
  set ocidPlistDict to item 1 of listReadPlistData
  set ocidCfbundlName to (ocidPlistDict's valueForKey:"CFBundleName")
  set strCfbundlName to ocidCfbundlName as text
  
  set strURL to ("" & strBaseURL & strCfbundlName & "/all") as text
  ##URLのオープンの仕方はお好みで
  tell application "Finder"
open location strURL
  end tell
  
end repeat






|

« Microsoft Teams (work or school)バージョンチェッカー | トップページ | [BASH]NTP設定 »

Admin」カテゴリの記事