Admin Pkg

RosettaUpdateAuto


#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
#################################################
/usr/sbin/softwareupdate --install-rosetta --agree-to-license

/usr/bin/grep RosettaUpdateAuto.pkg /var/log/install.log >"$HOME/Library/Logs/RosettaUpdateAuto.log"

/bin/launchctl kickstart -k -p system/com.apple.oahd


/usr/bin/notifyutil -p com.apple.oah.did-install

exit 0


|

PayloadFreePackageCreator


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#パッケージのみ作成 署名はしないのでそのままでは使えない
#オリジナルは
# https://github.com/rtrouton/Payload-Free-Package-Creator
# ↑このスクリプトを単体にしただけ
# オリジナルがMITライセンスなのでこのスクリプトもMITライセンスになります
#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

##バンドルID
set strBundleID to ("com.cocolog-nifty.quicktimer") as text
##バージョン(面倒なので日付にした)
set strVersion to doGetDateNo("yyyyMMdd") as text


#############################
###ダイアログ
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
############ デフォルトロケーション
tell application "Finder"
  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell

############UTIリスト
set listUTI to {"public.bash-script", "public.shell-script", "public.zsh-script"}
set strMes to ("シェルスクリプトファイルを選んでください") as text
set strPrompt to ("シェルスクリプトファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
on error
  log "エラーしました"
return "エラーしました"
end try
###スクリプトのパス
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 ocidBaseFilePath to ocidFilePath's stringByDeletingPathExtension()
set ocidFileName to ocidBaseFilePath's lastPathComponent()
set strFileName to ocidFileName as text
###テンポラリ内で生成
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTempDirURL to appFileManager's temporaryDirectory()
##UUIDをフォルダ名とする
set ocidUUID to refMe's NSUUID's alloc()'s init()
set strUUID to ocidUUID's UUIDString as text
set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(strUUID) isDirectory:true
set ocidSaveDirPath to ocidSaveDirPathURL's |path|()
###作業用フォルダUUID
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtPath:(ocidSaveDirPath) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###必要なフォルダ
set ocidPkgDirPath to ocidSaveDirPath's stringByAppendingPathComponent:(strFileName)
set ocidNopayloadDirPath to ocidPkgDirPath's stringByAppendingPathComponent:("nopayload")
set ocidScriptsDirPath to ocidPkgDirPath's stringByAppendingPathComponent:("scripts")
###↑各種フォルダ生成
set listBoolMakeDir to appFileManager's createDirectoryAtPath:(ocidPkgDirPath) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
set listBoolMakeDir to appFileManager's createDirectoryAtPath:(ocidNopayloadDirPath) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
set listBoolMakeDir to appFileManager's createDirectoryAtPath:(ocidScriptsDirPath) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###postinstallファイルのコピー
set ocidPostinstallFilePath to ocidScriptsDirPath's stringByAppendingPathComponent:("postinstall")
set listDone to appFileManager's copyItemAtPath:(ocidFilePath) toPath:(ocidPostinstallFilePath) |error|:(reference)
#アクセス権777
set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidPostinstallFilePath) |error|:(reference)
###PKG出来上がり予定パス
set strPkgFileName to (strFileName & "." & strVersion & ".pkg") as text
set ocidPkgFilePath to ocidPkgDirPath's stringByAppendingPathComponent:(strPkgFileName)
###コマンド用にテキスト形式に
set strPkgFilePath to ocidPkgFilePath as text
set strNopayloadDirPath to ocidNopayloadDirPath as text
set strScriptsDirPath to ocidScriptsDirPath as text

###パッケージ作成
##set strCommandText to ("/usr/bin/pkgbuild --identifier \"" & strBundleID & "\" --version \"" & strVersion & "\" --scripts \"" & strScriptsDirPath & "\" --root \"" & strNopayloadDirPath & "\" \"" & strPkgFilePath & "\"") as text

set strCommandText to ("/usr/bin/pkgbuild --nopayload --identifier \"" & strBundleID & "\" --version \"" & strVersion & "\" --scripts \"" & strScriptsDirPath & "\" --root \"" & strNopayloadDirPath & "\"  \"" & strPkgFilePath & "\"") as text
do shell script strCommandText

##スクリプトと同階層に移動
set ocidContainerDirPath to ocidFilePath's stringByDeletingLastPathComponent()
set ocidMovePkgFilePath to ocidContainerDirPath's stringByAppendingPathComponent:(strPkgFileName)
set listDone to appFileManager's moveItemAtPath:(ocidPkgFilePath) toPath:(ocidMovePkgFilePath) |error|:(reference)

return


##############################
### 今の日付日間 テキスト
##############################
to doGetDateNo(argDateFormat)
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
  set ocidTimeZone to refMe's NSTimeZone's alloc()'s initWithName:"Asia/Tokyo"
ocidNSDateFormatter's setTimeZone:(ocidTimeZone)
ocidNSDateFormatter's setDateFormat:(argDateFormat)
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo

|

インストールしたPKGを忘れるforget


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

#!/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 appFileManager to refMe's NSFileManager's defaultManager()

set strCommandText to ("/usr/sbin/pkgutil --packages") as text
set strResponse to (do shell script strCommandText) as text

set AppleScript's text item delimiters to "\r"
set listPKGID to every text item of strResponse
set AppleScript's text item delimiters to ""



set ocidArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidArrayM's addObjectsFromArray:listPKGID

set ocidDescriptor to refMe's NSSortDescriptor's sortDescriptorWithKey:("self") ascending:(yes) selector:"localizedStandardCompare:"
set ocidDescriptorArray to refMe's NSArray's arrayWithObject:(ocidDescriptor)
set ocidSortedArray to ocidArrayM's sortedArrayUsingDescriptors:(ocidDescriptorArray)

set listSortedArray to {} as list

repeat with itemArray in ocidSortedArray
  set end of listSortedArray to (itemArray as text)
end repeat


#############################
###ダイアログ
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
############ デフォルトロケーション
try
  set listResponse to (choose from list listSortedArray with title "選んだください" with prompt "pkgを忘れます" default items (item 1 of listSortedArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
end if
set strPKID to listResponse as text
set strCommandText to ("/usr/bin/sudo /usr/sbin/pkgutil -v --forget '" & strPKID & "'") as text
set strResponse to (do shell script strCommandText) as text
if strResponse is "false" then
  set strCommandText to ("/usr/sbin/pkgutil -v --forget " & strPKID & "") as text
  set strResponse to (do shell script strCommandText) as text
end if

return

|

パッケージ解凍(第2階層まで)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# 第2階層まで解凍する
# フォルダ名を明確にした
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions


property refMe : a reference to current application

######ファイルのオープン
on run
  set theWithPrompt to "flat packageを拡張してbundles packageに変換します"
  set theDefLoc to path to downloads folder from user domain
  set theFileTypeList to {"com.apple.installer-package-archive"} as list
  set aliasFilePathAlias to (choose file default location theDefLoc ¬
    with prompt theWithPrompt ¬
    of type theFileTypeList ¬
invisibles true ¬
    with showing package contents without multiple selections allowed)
open aliasFilePathAlias
end run

######ドロップのオープン
on open aliasFilePathAlias
  
  set appFileManager to refMe's NSFileManager's defaultManager()
  set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
  
  ####選択したパッケージのパス
  set strOrigFilePath to POSIX path of aliasFilePathAlias as text
  set ocidOrigPkgFilePath to (refMe's NSString's stringWithString:strOrigFilePath)
  set ocidOrigFileName to ocidOrigPkgFilePath's lastPathComponent()
  set strBaseFileName to ocidOrigFileName's stringByDeletingPathExtension()
  
  ####ユーザーダウンロードフォルダ
  set ocidUserDownloadsPathArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidUserDownloadsPathURL to ocidUserDownloadsPathArray's objectAtIndex:0
  #####展開フォルダ名
  set strDirName to ("解凍済" & strBaseFileName) as text
  set ocidSaveDirPathURL to ocidUserDownloadsPathURL's URLByAppendingPathComponent:(strDirName)
  ###フォルダを作る
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  
  
  ###pkgの展開先
  set ocidExpandPkgPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strBaseFileName)
  set strSaveDirPathURL to ocidExpandPkgPathURL's |path|() as text
  ####コマンド実行
  set theComandText to "/usr/sbin/pkgutil --expand \"" & strOrigFilePath & "\" \"" & strSaveDirPathURL & "\"" as text
  do shell script theComandText
  ####展開 パッケージを調べて
  set listResult to appFileManager's contentsOfDirectoryAtURL:ocidExpandPkgPathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
  set listFilePathURLArray to item 1 of listResult
  ####内包されているファイル
  repeat with itemFilePathURLArray in listFilePathURLArray
    ####拡張子PKGだけ実施
    set strExtension to itemFilePathURLArray's pathExtension() as text
    if strExtension is "pkg" then
      set ocidPkgName to itemFilePathURLArray's lastPathComponent()
      
      
      set strPkgFolderName to (ocidPkgName as text) & "_Folder"
      set ocidDistPathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:strPkgFolderName)
      set boolMoveFileAndRename to (appFileManager's moveItemAtURL:itemFilePathURLArray toURL:ocidDistPathURL |error|:(reference))
      set ocidPayLoardPathURL to (ocidDistPathURL's URLByAppendingPathComponent:"Payload")
      set strPayLoardPathURL to ocidPayLoardPathURL's |path|() as text
      set strSaveDirPathURL to (ocidPayLoardPathURL's URLByDeletingLastPathComponent())'s |path|() as text
      #####解凍コピー
      try
        set theComandText to ("/usr/bin/ditto -xz \"" & strPayLoardPathURL & "\"   \"" & strSaveDirPathURL & "\"") as text
        do shell script theComandText
      end try
    end if
  end repeat
  #############################
  ###Finderでフォルダを開く
  #############################
appShardWorkspace's openURL:ocidExpandPkgPathURL
end open


|

パッケージ解凍(第一階層のみ)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# フォルダ名を明確にした 第一階層のみ解凍
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions


property refMe : a reference to current application

######ファイルのオープン
on run
  set theWithPrompt to "flat packageを拡張してbundles packageに変換します"
  set theDefLoc to path to downloads folder from user domain
  set theFileTypeList to {"com.apple.installer-package", "com.apple.application-bundle", "com.apple.installer-package-archive"} as list
  set aliasFilePathAlias to (choose file default location theDefLoc ¬
    with prompt theWithPrompt ¬
    of type theFileTypeList ¬
invisibles true ¬
    with showing package contents without multiple selections allowed)
open aliasFilePathAlias
end run

######ドロップのオープン
on open aliasFilePathAlias
  
  set appFileManager to refMe's NSFileManager's defaultManager()
  set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
  
  ####選択したパッケージのパス
  set strOrigFilePath to POSIX path of aliasFilePathAlias as text
  set ocidOrigPkgFilePath to (refMe's NSString's stringWithString:strOrigFilePath)
  set ocidOrigFileName to ocidOrigPkgFilePath's lastPathComponent()
  set strBaseFileName to ocidOrigFileName's stringByDeletingPathExtension()
  
  ####ユーザーダウンロードフォルダ
  set ocidUserDownloadsPathArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidUserDownloadsPathURL to ocidUserDownloadsPathArray's objectAtIndex:0
  #####展開フォルダ名
  set strDirName to ("解凍済" & strBaseFileName) as text
  set ocidSaveDirPathURL to ocidUserDownloadsPathURL's URLByAppendingPathComponent:(strDirName)
  ###フォルダを作る
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  
  
  ###pkgの展開先
  set ocidExpandPkgPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strBaseFileName)
  set strSaveDirPathURL to ocidExpandPkgPathURL's |path|() as text
  ####コマンド実行
  set theComandText to "/usr/sbin/pkgutil --expand \"" & strOrigFilePath & "\" \"" & strSaveDirPathURL & "\"" as text
  do shell script theComandText
  
  #############################
  ###Finderでフォルダを開く
  #############################
appShardWorkspace's openURL:ocidExpandPkgPathURL
end open


|

[PKG]パッケージ解凍 少し追加


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# フォルダ名を明確にした
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions


property refMe : a reference to current application

######ファイルのオープン
on run
  set theWithPrompt to "flat packageを拡張してbundles packageに変換します"
  set theDefLoc to path to downloads folder from user domain
  set theFileTypeList to {"com.apple.installer-package-archive"} as list
  set aliasFilePathAlias to (choose file default location theDefLoc ¬
    with prompt theWithPrompt ¬
    of type theFileTypeList ¬
invisibles true ¬
    with showing package contents without multiple selections allowed)
open aliasFilePathAlias
end run

######ドロップのオープン
on open aliasFilePathAlias
  
  set appFileManager to refMe's NSFileManager's defaultManager()
  set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
  
  ####選択したパッケージのパス
  set strOrigFilePath to POSIX path of aliasFilePathAlias as text
  set ocidOrigPkgFilePath to (refMe's NSString's stringWithString:strOrigFilePath)
  set ocidOrigFileName to ocidOrigPkgFilePath's lastPathComponent()
  set strBaseFileName to ocidOrigFileName's stringByDeletingPathExtension()
  
  ####ユーザーダウンロードフォルダ
  set ocidUserDownloadsPathArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidUserDownloadsPathURL to ocidUserDownloadsPathArray's objectAtIndex:0
  #####展開フォルダ名
  set strDirName to ("解凍済" & strBaseFileName) as text
  set ocidSaveDirPathURL to ocidUserDownloadsPathURL's URLByAppendingPathComponent:(strDirName)
  ###フォルダを作る
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  
  
  ###pkgの展開先
  set ocidExpandPkgPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strBaseFileName)
  set strSaveDirPathURL to ocidExpandPkgPathURL's |path|() as text
  ####コマンド実行
  set theComandText to "/usr/sbin/pkgutil --expand \"" & strOrigFilePath & "\" \"" & strSaveDirPathURL & "\"" as text
  do shell script theComandText
  ####展開 パッケージを調べて
  set listResult to appFileManager's contentsOfDirectoryAtURL:ocidExpandPkgPathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
  set listFilePathURLArray to item 1 of listResult
  ####内包されているファイル
  repeat with itemFilePathURLArray in listFilePathURLArray
    ####拡張子PKGだけ実施
    set strExtension to itemFilePathURLArray's pathExtension() as text
    if strExtension is "pkg" then
      set ocidPkgName to itemFilePathURLArray's lastPathComponent()
      
      
      set strPkgFolderName to (ocidPkgName as text) & "_Folder"
      set ocidDistPathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:strPkgFolderName)
      set boolMoveFileAndRename to (appFileManager's moveItemAtURL:itemFilePathURLArray toURL:ocidDistPathURL |error|:(reference))
      set ocidPayLoardPathURL to (ocidDistPathURL's URLByAppendingPathComponent:"Payload")
      set strPayLoardPathURL to ocidPayLoardPathURL's |path|() as text
      set strSaveDirPathURL to (ocidPayLoardPathURL's URLByDeletingLastPathComponent())'s |path|() as text
      #####解凍コピー
      try
        set theComandText to ("/usr/bin/ditto -xz \"" & strPayLoardPathURL & "\"   \"" & strSaveDirPathURL & "\"") as text
        do shell script theComandText
      end try
    end if
  end repeat
  #############################
  ###Finderでフォルダを開く
  #############################
appShardWorkspace's openURL:ocidExpandPkgPathURL
end open


|

pkgを解凍する

少し直した

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions


property refMe : a reference to current application

######ファイルのオープン
on run
  set theWithPrompt to "flat packageを拡張してbundles packageに変換します"
  set theDefLoc to path to downloads folder from user domain
  set theFileTypeList to {"com.apple.installer-package-archive"} as list
  set aliasFilePathAlias to (choose file default location theDefLoc ¬
    with prompt theWithPrompt ¬
    of type theFileTypeList ¬
    invisibles true ¬
    with showing package contents without multiple selections allowed)
  open aliasFilePathAlias
end run

######ドロップのオープン
on open aliasFilePathAlias
  
  set appFileManager to refMe's NSFileManager's defaultManager()
  set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
  
  ####選択したパッケージのパス
  set strOrigFilePath to POSIX path of aliasFilePathAlias as text
  set ocidOrigPkgFilePath to (refMe's NSString's stringWithString:strOrigFilePath)
  set ocidOrigFileName to ocidOrigPkgFilePath's lastPathComponent()
  set strBaseFileName to ocidOrigFileName's stringByDeletingPathExtension()
  
  ####ユーザーダウンロードフォルダ
  set ocidUserDownloadsPathArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidUserDownloadsPathURL to ocidUserDownloadsPathArray's objectAtIndex:0
  #####展開フォルダ名
  
  set ocidSaveDirPathURL to ocidUserDownloadsPathURL's URLByAppendingPathComponent:"解凍したパッケージ"
  ###フォルダを作る
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
  ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  ###pkgの展開先
  set ocidExpandPkgPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:strBaseFileName
  set strSaveDirPathURL to ocidExpandPkgPathURL's |path|() as text
  ####コマンド実行
  set theComandText to "/usr/sbin/pkgutil  --expand  \"" & strOrigFilePath & "\" \"" & strSaveDirPathURL & "\"" as text
  do shell script theComandText
  ####展開 パッケージを調べて
  set listResult to appFileManager's contentsOfDirectoryAtURL:ocidExpandPkgPathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
  set listFilePathURLArray to item 1 of listResult
  ####内包されているファイル
  repeat with itemFilePathURLArray in listFilePathURLArray
    ####拡張子PKGだけ実施
    set strExtension to itemFilePathURLArray's pathExtension() as text
    if strExtension is "pkg" then
      set ocidPkgName to itemFilePathURLArray's lastPathComponent()
      set strPkgFolderName to (ocidPkgName as text) & "_Folder"
      set ocidDistPathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:strPkgFolderName)
      set boolMoveFileAndRename to (appFileManager's moveItemAtURL:itemFilePathURLArray toURL:ocidDistPathURL |error|:(reference))
      set ocidPayLoardPathURL to (ocidDistPathURL's URLByAppendingPathComponent:"Payload")
      set strPayLoardPathURL to ocidPayLoardPathURL's |path|() as text
      set strSaveDirPathURL to (ocidPayLoardPathURL's URLByDeletingLastPathComponent())'s |path|() as text
      #####解凍コピー
      try
        set theComandText to ("/usr/bin/ditto  -xz   \"" & strPayLoardPathURL & "\"   \"" & strSaveDirPathURL & "\"") as text
        do shell script theComandText
      end try
    end if
  end repeat
  #############################
  ###Finderでフォルダを開く
  #############################
  appShardWorkspace's openURL:ocidExpandPkgPathURL
end open

|

パッケージを解凍する

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions


property refMe : a reference to current application


on run
  set theWithPrompt to "flat packageを拡張してbundles packageに変換します"
  set theDefLoc to path to downloads folder from user domain
  set theFileTypeList to {"com.apple.installer-package-archive"} as list
  set aliasFilePathAlias to (choose file default location theDefLoc ¬
    with prompt theWithPrompt ¬
    of type theFileTypeList ¬
    invisibles true ¬
    with showing package contents without multiple selections allowed)
  open aliasFilePathAlias
end run


on open aliasFilePathAlias
  
  set appFileManager to refMe's NSFileManager's defaultManager()
  set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
  ####ユーザーダウンロードフォルダ
  set ocidUserDownloadsPathArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidUserDownloadsPathURL to ocidUserDownloadsPathArray's objectAtIndex:0
  ####選択したパッケージのパス
  set strOrigFilePath to POSIX path of aliasFilePathAlias as text
  set ocidOrigPkgFilePath to (refMe's NSString's stringWithString:strOrigFilePath)
  set strOrigFileName to ocidOrigPkgFilePath's lastPathComponent() as text
  set strCopyFileName to (strOrigFileName & ".copy.pkg") as text
  set strUserDownloadsPath to ocidUserDownloadsPathURL's |path| as text
  set strPkgFilePath to (strUserDownloadsPath & strCopyFileName) as text
  
  set theComandText to ("/usr/bin/ditto  \"" & strOrigFilePath & "\"   \"" & strPkgFilePath & "\"") as text
  do shell script theComandText
  
  set ocidPkgFilePath to (refMe's NSString's stringWithString:strPkgFilePath)
  set ocidPkgFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidPkgFilePath isDirectory:false
  set ocidFileName to ocidPkgFilePathURL's lastPathComponent()
  set strBaseFileName to ocidFileName's stringByDeletingPathExtension()
  #####展開フォルダ名
  set strDirName to ("解凍したパッケージ" & strBaseFileName) as text
  set ocidSaveDirPathURL to ocidUserDownloadsPathURL's URLByAppendingPathComponent:strDirName
  set strSaveDirPathURL to ocidSaveDirPathURL's |path|() as text
  ####コマンド実行
  set theComandText to "/usr/sbin/pkgutil  --expand  \"" & strPkgFilePath & "\" \"" & strSaveDirPathURL & "\"" as text
  do shell script theComandText
  ####展開 パッケージを調べて
  set listResult to appFileManager's contentsOfDirectoryAtURL:ocidSaveDirPathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
  set listFilePathURLArray to item 1 of listResult
  ####内包されているファイル
  repeat with itemFilePathURLArray in listFilePathURLArray
    ####拡張子PKGだけ実施
    set strExtension to itemFilePathURLArray's pathExtension() as text
    if strExtension is "pkg" then
      set ocidPkgName to itemFilePathURLArray's lastPathComponent()
      set strPkgFolderName to (ocidPkgName as text) & "_Folder"
      set ocidDistPathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:strPkgFolderName)
      set boolMoveFileAndRename to (appFileManager's moveItemAtURL:itemFilePathURLArray toURL:ocidDistPathURL |error|:(reference))
      set ocidPayLoardPathURL to (ocidDistPathURL's URLByAppendingPathComponent:"Payload")
      set strPayLoardPathURL to ocidPayLoardPathURL's |path|() as text
      set strSaveDirPathURL to (ocidPayLoardPathURL's URLByDeletingLastPathComponent())'s |path|() as text
      #####解凍コピー
      try
        set theComandText to ("/usr/bin/ditto  -xz   \"" & strPayLoardPathURL & "\"   \"" & strSaveDirPathURL & "\"") as text
        do shell script theComandText
      end try
    end if
  end repeat
  #############################
  ###Finderでフォルダを開く
  #############################
  appShardWorkspace's openURL:ocidDistPathURL
end open

|

パッケージを解凍

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions


property refMe : a reference to current application



---ダブルクリックの始まり
on run
  ---プロンプトの文言改行が使えます。改行入れる所には『\n』を入れます
  set theWithPrompt to "flat packageを拡張してbundles packageに変換します"
  ---ファイル選択ダイアログのデフォルトのディレクトリ
  set theDefLoc to path to downloads folder from user domain
  ---UTI指定複数ある時はカンマで区切る
  ---本当は↓で動作するはずだが上手く動作しない
  ---set theFileType to "com.apple.installer-package,com.apple.application-bundle" as text
  
  set theFileTypeList to {"com.apple.installer-package-archive"} as list
  
  ---ダイアログを出して選択されたファイルは「open」に渡す
  set aliasFilePathAlias to (choose file default location theDefLoc ¬
    with prompt theWithPrompt ¬
    of type theFileTypeList ¬
    invisibles true ¬
    with showing package contents without multiple selections allowed)
  
  open aliasFilePathAlias
  
end run


on open aliasFilePathAlias
  set appFileManager to refMe's NSFileManager's defaultManager()
  set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
  
  set ocidUserDownloadsPathArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidUserDownloadsPathURL to ocidUserDownloadsPathArray's objectAtIndex:0
  
  
  set strPkgFilePath to POSIX path of aliasFilePathAlias as text
  set ocidPkgFilePath to (refMe's NSString's stringWithString:strPkgFilePath)
  set ocidPkgFilePathURL to refMe's NSURL's alloc()'s initWithString:ocidPkgFilePath
  set ocidFileName to ocidPkgFilePathURL's lastPathComponent()
  set strBaseFileName to ocidFileName's stringByDeletingPathExtension()
  
  set strDirName to ("解凍したパッケージ" & strBaseFileName) as text
  
  set ocidSaveDirPathURL to ocidUserDownloadsPathURL's URLByAppendingPathComponent:strDirName
  
  set strSaveDirPathURL to ocidSaveDirPathURL's |path|() as text
  
  set theComandText to "/usr/sbin/pkgutil  --expand  \"" & strPkgFilePath & "\" \"" & strSaveDirPathURL & "\"" as text
  do shell script theComandText
  #######################
  set listResult to appFileManager's contentsOfDirectoryAtURL:ocidSaveDirPathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
  set listFilePathURLArray to item 1 of listResult
  
  repeat with itemFilePathURLArray in listFilePathURLArray
    
    set strExtension to itemFilePathURLArray's pathExtension() as text
    if strExtension is "pkg" then
      set ocidPkgName to itemFilePathURLArray's lastPathComponent()
      set strPkgFolderName to (ocidPkgName as text) & "_Folder"
      set ocidDistPathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:strPkgFolderName)
      set boolMoveFileAndRename to (appFileManager's moveItemAtURL:itemFilePathURLArray toURL:ocidDistPathURL |error|:(reference))
      set ocidPayLoardPathURL to (ocidDistPathURL's URLByAppendingPathComponent:"Payload")
      set strPayLoardPathURL to ocidPayLoardPathURL's |path|() as text
      set strSaveDirPathURL to (ocidPayLoardPathURL's URLByDeletingLastPathComponent())'s |path|() as text
      
      
      try
        set theComandText to ("/usr/bin/ditto  -xz   \"" & strPayLoardPathURL & "\"   \"" & strSaveDirPathURL & "\"") as text
        do shell script theComandText
      end try
    end if
  end repeat
  #############################
  ###Finderでフォルダを開く
  #############################
  appShardWorkspace's openURL:ocidDistPathURL
end open

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom