20260416

3_アプリ指定サンプル.scpt 4_アプリ指定サンプル.applescript

3_アプリ指定サンプル.scpt

NOTE記事一覧ですnote.com

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

3_アプリ指定サンプル.scpt.scpt
ソース
001#!/usr/bin/env osascript
002#coding: utf-8
003----+----1----+----2----+-----3----+----4----+----5----+----6----+----7--
004(*
005テスト用のサンプルスクリプト
006複数のファイルを
007HTMLファイルをデフォルトのWEBブラウザ
008(HTMLと関連づけられているアプリケーション)で開きます
009
010
011
012バンドルIDを指定(開くアプリケーションを指定)して開きます
013この方法だと発生しない
014noteの記事用のデモスクリプト
015https://note.com/quicktimer/n/nd0342b80d2f7
016
017com.cocolog-nifty.quicktimer.icefloe *)
018----+----1----+----2----+-----3----+----4----+----5----+----6----+----7--
019use AppleScript version "2.8"
020use scripting additions
021
022set listFilePath to {"/Library/Documentation/License.lpdf/Contents/Resources/English.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/German.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/French.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Dutch.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Italian.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Japanese.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Spanish.lproj/License.html"} as list
023
024set listAliasFilePath to {} as list
025repeat with itemFilePath in listFilePath
026   set itemAlisFilePath to (POSIX file itemFilePath) as alias
027   set end of listAliasFilePath to itemAlisFilePath
028end repeat
029
030
031repeat with itemAliasFilePath in listAliasFilePath
032   set aliasFilePath to itemAliasFilePath as alias
033   
034   tell file aliasFilePath
035      set recordInfoFor to (info for) as record
036   end tell
037   
038   set strUTI to (type identifier of recordInfoFor) as text
039   
040   if strUTI starts with "dyn." then
041      tell application "Finder"
042         open file alisFilePath
043      end tell
044      tell application "Finder" to activate
045   else
046      set aliaAppPath to (default application of recordInfoFor) as alias
047      tell file aliaAppPath
048         set recordInfoFor to (info for) as record
049      end tell
050      set strBundleID to (bundle identifier of recordInfoFor) as text
051      tell application id strBundleID
052         open location aliasFilePath
053      end tell
054   end if
055   
056   
057end repeat
058
059
060return
061
AppleScriptで生成しました