AppleScript Preview

画像が入っているフォルダを開く(ファイル名順)少し修正

プレビューアプリのテンポラリーデータを削除(ゴミ箱に入れる)処理を追加した

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

#!/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 "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application
property strBundleID : "com.apple.Preview"

###Wクリックで起動した場合
on run
  set aliasDefaultLocation to (path to desktop from user domain) as alias
  set strPromptText to "画像が入ったフォルダをえらんでください"
  set strMesText to "画像が入ったフォルダをえらんでください"
  try
    set listFolderPath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
  on error
log "エラーしました"
return "エラーしました"
  end try
open listFolderPath
end run

###ドロップで起動した場合
on open listFolderPath
  ####################################
  ####フォルタ以外は処理しない
  repeat with itemFolderPath in listFolderPath
    set aliasFolderPath to itemFolderPath as alias
    set strFilePath to (POSIX path of aliasFolderPath) 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))
    set listBoole to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference))
    set boolIsDir to (item 2 of listBoole) as boolean
    if boolIsDir is true then
log "フォルダなので処理開始"
    else
return "フォルダ以外は処理しない"
    end if
  end repeat
  
  ####################################
  ####プレビューを一度終了させてから処理させる
  tell application id strBundleID to activate
  repeat 3 times
    try
delay 0.2
      tell application id strBundleID to close every window
    on error
      tell application id strBundleID to quit
    end try
delay 0.2
  end repeat
  tell application id strBundleID to quit
  ####プレビューの半ゾンビ化対策
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
  repeat with itemAppArray in ocidAppArray
delay 0.2
itemAppArray's terminate()
  end repeat
  ################################
  ##テンポラリーをゴミ箱に
  ################################
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
  set ocidTmpDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Containers/com.apple.Preview/Data/tmp")
  set listResult to (appFileManager's trashItemAtURL:(ocidTmpDirPathURL) resultingItemURL:(ocidTmpDirPathURL) |error|:(reference))
  ##
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
  # 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidTmpDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  
  ################################
  ##【本処理】フォルダの数だけ繰り返し
  ################################
  ###enumeratorAtURL用のBoolean用
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)
  
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLAllArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ###まずは全部のURLをArrayに入れる
  repeat with itemFolderPath in listFolderPath
    ######パス フォルダのエイリアス
    set aliasDirPath to itemFolderPath as alias
    ###UNIXパスにして
    set strDirPath to POSIX path of aliasDirPath as text
    ###Stringsに
    set ocidDirPath to (refMe's NSString's stringWithString:strDirPath)
    ###パス確定させて
    set ocidDirPath to ocidDirPath's stringByStandardizingPath
    ###NSURLに
    set ocidDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidDirPath isDirectory:true)
    ##################################
    ##プロパティ
    set ocidPropertieKey to {refMe's NSURLPathKey, refMe's NSURLIsRegularFileKey, refMe's NSURLContentTypeKey}
    ##オプション(隠しファイルは含まない)
    set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
    ####ディレクトリのコンテツを収集(最下層まで)
    set ocidEmuDict to (appFileManager's enumeratorAtURL:ocidDirPathURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption errorHandler:(reference))
    ###戻り値をリストに格納
    set ocidEmuFileURLArray to ocidEmuDict's allObjects()
(ocidFilePathURLAllArray's addObjectsFromArray:ocidEmuFileURLArray)
  end repeat
  ################################
  ####必要なファイルだけのArrayにする
  ################################
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidFilePathURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ####URLの数だけ繰り返し
  repeat with itemFilePathURL in ocidFilePathURLAllArray
    ###################不要なファイルをゴミ箱に入れちゃう
    ####拡張子取って
    set ocidExtension to itemFilePathURL's pathExtension()

      ####URLをforKeyで取り出し
      set listResult to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsRegularFileKey) |error|:(reference))
      ###リストからNSURLIsRegularFileKeyのBOOLを取り出し
      set boolIsRegularFileKey to item 2 of listResult
      ####ファイルのみを(ディレクトリやリンボリックリンクは含まない)
      if boolIsRegularFileKey is ocidTrue then
        ####リストにする
(ocidFilePathURLArray's addObject:(itemFilePathURL))
      end if

  end repeat
log ocidFilePathURLArray as list
  ################################
  ####ファイルタイプのチェックをする
  ################################
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  set listUTI to doGetUTI() as list
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLArrayM to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  repeat with itemFilePathURL in ocidFilePathURLArray
    ####UTIの取得
    set listResourceValue to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))
    set ocidContentType to (item 2 of listResourceValue)
    set strUTI to (ocidContentType's identifier) as text
    if listUTI contains strUTI then
(ocidFilePathURLArrayM's addObject:(itemFilePathURL))
    end if
  end repeat
  
log ocidFilePathURLArrayM as list
  ##############################
  ####並び替え並び替え compare
  ##############################
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  (*
compare:
caseInsensitiveCompare:
localizedCompare:
localizedStandardCompare:
localizedCaseInsensitiveCompare:
*)
  set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
  
  ## set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"compare:")
(ocidFilePathURLArrayM's sortUsingDescriptors:{ocidSortDescriptor})
  
  ##############################
  ####エリアスリストにして
  ##############################
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  ###空のリスト=プレヴューに渡すため
  set listAliasPath to {} as list
  ###並び変わったファイルパスを順番に
  repeat with itemFilePathURL in ocidFilePathURLArrayM
    ###エイリアスにして
    set aliasFilePath to (itemFilePathURL's absoluteURL()) as alias
    ####リストに格納していく
    copy aliasFilePath to end of listAliasPath
  end repeat
  if listAliasPath is {} then
return "Openできる書類はありませんでした"
  end if
  ##############################
  ####起動
  ##############################
  try
    tell application id "com.apple.Preview" to launch
  on error
    tell application id "com.apple.Preview" to activate
  end try
  ##############################
  ####プレビューで開く
  ##############################
  tell application id "com.apple.Preview"
activate
    set numWindow to count of window
    if numWindow = 0 then
      try
open listAliasPath
      on error
log "ここでエラー"
      end try
    else
      ####新しいウィンドで開く方法がわからん
      ####新しいインスタンス生成すれば良いのかな
open listAliasPath
    end if
  end tell
  
end open





to doGetUTI()
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  ###アプリケーションのURLを取得
  ###NSバンドルをUTIから取得
  set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
  if ocidAppBundle = (missing value) then
    ###NSバンドル取得できなかった場合
    set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
    set ocidAppPathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
  else
    set ocidAppPathURL to ocidAppBundle's bundleURL()
  end if
  ###Plistのパス
  set ocidPlistPathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
  set ocidDocTypeArray to ocidPlistDict's objectForKey:"CFBundleDocumentTypes"
  if ocidDocTypeArray = (missing value) then
    set strOutPutText to "missing value" as text
  else
    ####リストにする
    set listUTl to {} as list
    ###対応ドキュメントタイプをリストにしていく
    repeat with itemDocTypeArray in ocidDocTypeArray
      set listContentTypes to (itemDocTypeArray's objectForKey:"LSItemContentTypes")
      if listContentTypes = (missing value) then
        ###拡張子の指定のみの場合
        set ocidExtension to (itemDocTypeArray's objectForKey:"CFBundleTypeExtensions")
        set strClassName to ocidExtension's className() as text
        repeat with itemExtension in ocidExtension
          set strExtension to itemExtension as text
          set ocidContentTypes to (refMe's UTType's typeWithFilenameExtension:(strExtension))
          set strContentTypes to ocidContentTypes's identifier() as text
          set strContentTypes to ("" & strContentTypes & "") as text
          set end of listUTl to (strContentTypes)
        end repeat
      else
        repeat with itemContentTypes in listContentTypes
          set strContentTypes to ("" & itemContentTypes & "") as text
          set end of listUTl to (strContentTypes)
        end repeat
      end if
    end repeat
  end if
return listUTl
end doGetUTI

|

[com.apple.Preview]開いている画像を全て上書き保存


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

#!/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 scripting additions

################################
###起動
tell application id "com.apple.Preview"
activate
end tell
################################
###ウィンドウ チェック
tell application id "com.apple.Preview"
activate
  set numCntWin to (count of window) as integer
  if numCntWin = 0 then
return "ウィンドウがありません"
  end if
end tell

################################
###ドキュメント チェック
tell application id "com.apple.Preview"
activate
  set numCntDoc to (count of document) as integer
log numCntDoc
  if numCntDoc = 0 then
return "ドキュメントがありません"
  end if
end tell
################################
###全てのドキュメントを上書き保存
tell application id "com.apple.Preview"
  set listEveryDoc to (every document)
  repeat with itemDoc in listEveryDoc
    tell itemDoc
save
    end tell
  end repeat
end tell








|

[Preview]PDF奇数ページ偶数ページ入れ替え


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

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

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

##################################
###スクリプトメニューから実行したら
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder"
    activate
  end tell
else
  tell current application
    activate
  end tell
end if
##################################
###起動
tell application "Preview" to launch
###前面に
tell application id "com.apple.Preview"
  set boolFrontMost to frontmost as boolean
end tell
###最大5秒待つ
repeat 10 times
  if boolFrontMost is false then
    exit repeat
  else
    tell application "Preview" to activate
    delay 0.5
  end if
end repeat
##################################
### ウィンドウがあるか?
tell application "Preview"
  set numCntDoc to (count of every window) as integer
end tell
if numCntDoc = 0 then
  display alert "エラー:pdfを開いていません" buttons {"OK", "キャンセル"} default button "OK" as informational giving up after 10
return "ウィンドウがありませんPDFを開いてね"
end if
##################################
### PDF文書を開いているか?
tell application "Preview"
  tell front document
    set strFileName to name as text
  end tell
end tell
if strFileName does not contain "PDF" then
  display alert "エラー:pdfを開いていません" buttons {"OK", "キャンセル"} default button "OK" as informational giving up after 10
return "ウィンドウがありませんPDFを開いてね"
else
  ###PDFを開いているならパスを取得する
  tell application "Preview"
    tell front document
      set strFilePath to path as text
    end tell
  end tell
end if
##################################
###変更箇所があるなら保存して閉じる
tell application "Preview"
  tell front document
    set boolMode to modified
    ###変更箇所があるなら保存する
    if boolMode is true then
close saving yes
    else
close saving no
    end if
  end tell
end tell
#################################
### 本処理
###パス処理
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:false)
##########################
####PDFファイルを格納
set ocidPDFDocument to (refMe's PDFDocument's alloc()'s initWithURL:(ocidFilePathURL))
####ページ数
set numPageCnt to ocidPDFDocument's pageCount() as integer

if numPageCnt = 1 then
  log "1ページの場合は処理できない"
return "1ページの場合は処理できない"
else
  ###ページ数カウンター
  set numCntPageNo to 0 as number
  repeat numPageCnt times
    ####偶数奇数判定 mod=割った時に小数点以下があるか?
    set numChkPageOddEven to (numCntPageNo mod 2) as number
    ###0なら奇数
    if numChkPageOddEven = 0 then
ocidPDFDocument's exchangePageAtIndex:(numCntPageNo) withPageAtIndex:(numCntPageNo + 1)
    else if numChkPageOddEven = 1 then
      ###0なら奇数処理は奇数ページで行い偶数ページは操作しない
      log "偶数ページ"
    end if
    set numCntPageNo to numCntPageNo + 1 as number
  end repeat
end if
#################################
###保存する
ocidPDFDocument's writeToURL:(ocidFilePathURL)
#################################
set aliasFilePath to (POSIX file strFilePath) as alias
###開く
tell application "Preview"
  open file aliasFilePath
end tell

return

|

[Preview]アプリケーションの終了(修正)


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

#!/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 "AppKit"
use scripting additions

property refMe : a reference to current application


set strBundleID to "com.apple.Preview" as text

set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
repeat with itemAppArray in ocidAppArray
itemAppArray's terminate()
end repeat
delay 0.5
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
set numCntArray to ocidAppArray count
if numCntArray ≠ 0 then
  repeat with itemAppArray in ocidAppArray
itemAppArray's forceTerminate()
  end repeat
else if numCntArray = 0 then
return "全プロセス終了しました1"
end if
delay 0.5
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
set numCntArray to ocidAppArray count
if numCntArray = 0 then
return "全プロセス終了しました2"
else
  delay 1
itemAppArray's forceTerminate()
end if

return

|

[Preview]画像フォルダを開く(新規ウィンドウ= setCreatesNewApplicationInstance)

どうも…うまくいかない

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

#!/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 "Appkit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

###設定項目 新規インスタンスで開くか?
property boolNewInstance : true as boolean
###開くアプリケーション
property strBundleID : "com.apple.Preview"

on run
  ###デスクトップ
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidHomeDirURL to appFileManager's homeDirectoryForCurrentUser()
  set ocidDesktopDirURL to ocidHomeDirURL's URLByAppendingPathComponent:("Desktop") isDirectory:(true)
  set aliasDefaultLocation to (ocidDesktopDirURL's absoluteURL()) as alias
  set strPromptText to "画像が入ったフォルダをえらんでください"
  set strMesText to "画像が入ったフォルダをえらんでください"
  try
    set listFolderPath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
open listFolderPath
end run


on open listFolderPath
  ####################################
  ###フォルダURLのみを格納するリスト
  ####################################
  set ocidDirURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  repeat with itemFolderPath in listFolderPath
    set strDirPath to POSIX path of itemFolderPath as text
    set ocidDirPathStr to (refMe's NSString's stringWithString:(strDirPath))
    set ocidDirPath to ocidDirPathStr's stringByStandardizingPath
    ###NSURLに
    set ocidDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidDirPath)
    set listResourceValue to (ocidDirPathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference))
    ###ディレクトリ=フォルダか?確認
    set boolIsDir to (item 2 of listResourceValue)
    if boolIsDir = (refMe's NSNumber's numberWithBool:true) then
(ocidDirURLArray's addObject:(ocidDirPathURL))
    end if
  end repeat
  ####################################
  ###並び替えておく
  ####################################
  set ocidDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
(ocidDirURLArray's sortUsingDescriptors:{ocidDescriptor})
  (*
####################################
###プレビューを終了させる
####################################
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
repeat with itemAppArray in ocidAppArray
itemAppArray's terminate()
end repeat
repeat with itemAppArray in ocidAppArray
itemAppArray's forceTerminate()
end repeat
*)
  ###enumeratorAtURL用のBoolean用
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  
  ################################
  ####フォルダの数だけ繰り返し
  ################################
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLAllArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ###まずは全部のURLをArrayに入れる
  repeat with itemDirURLArray in ocidDirURLArray
    ###NSURLに
    set ocidDirPathURL to itemDirURLArray
    ##################################
    ##プロパティ
    set ocidPropertieKey to {refMe's NSURLPathKey, refMe's NSURLIsRegularFileKey, refMe's NSURLContentTypeKey}
    ##オプション(隠しファイルは含まない)
    set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
    ####ディレクトリのコンテツを収集(最下層まで)
    set ocidEmuDict to (appFileManager's enumeratorAtURL:ocidDirPathURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption errorHandler:(reference))
    ###戻り値をリストに格納
    set ocidEmuFileURLArray to ocidEmuDict's allObjects()
(ocidFilePathURLAllArray's addObjectsFromArray:ocidEmuFileURLArray)
  end repeat
  
  
  
  
  ################################
  ####必要なファイルだけのArrayにする
  ################################
  set ocidFilePathURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ####URLの数だけ繰り返し
  repeat with itemFilePathURL in ocidFilePathURLAllArray
    ###################不要なファイルをゴミ箱に入れちゃう
    ####拡張子取って
    set ocidExtension to itemFilePathURL's pathExtension()
    ###URLファイル削除
    if (ocidExtension as text) is "url" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###WindowのサムネイルDB削除
    else if (ocidExtension as text) is "db" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###webloc削除
    else if (ocidExtension as text) is "webloc" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
    else
      ####URLをforKeyで取り出し
      set listResult to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsRegularFileKey) |error|:(reference))
      ###リストからNSURLIsRegularFileKeyのBOOLを取り出し
      set boolIsRegularFileKey to item 2 of listResult
      ####ファイルのみを(ディレクトリやリンボリックリンクは含まない)
      if boolIsRegularFileKey is ocidTrue then
####リストにする
(ocidFilePathURLArray's addObject:(itemFilePathURL))
      end if
    end if
  end repeat
  log ocidFilePathURLArray as list
  
  
  ################################
  ####ファイルタイプのチェックをする
  ################################
  set ocidAppPathURL to doGetAppURL(strBundleID)
  set listUTI to doGetUTI(ocidAppPathURL) as list
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLArrayM to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  repeat with itemFilePathURL in ocidFilePathURLArray
    ####UTIの取得
    set listResourceValue to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))
    set ocidContentType to (item 2 of listResourceValue)
    set strUTI to (ocidContentType's identifier) as text
    if listUTI contains strUTI then
(ocidFilePathURLArrayM's addObject:(itemFilePathURL))
    end if
  end repeat
  
  log ocidFilePathURLArrayM as list
  ##############################
  ####並び替え並び替え
  ##############################
  ## set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
  set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"compare:")
(ocidFilePathURLArrayM's sortUsingDescriptors:{ocidSortDescriptor})
  
  
  ##############################
  ####プレビューで開く
  ##############################
  set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
  ###新規インスタンスで開く設定
  set ocidConfig to refMe's NSWorkspaceOpenConfiguration's configuration()
ocidConfig's setActivates:(true)
ocidConfig's setAppleEvent:(true)
ocidConfig's setAllowsRunningApplicationSubstitution:(true)
ocidConfig's setAddsToRecentItems:(false)
ocidConfig's setHides:(false)
ocidConfig's setCreatesNewApplicationInstance:(boolNewInstance)
  ###ファイルAを開く
appSharedWorkspace's openURLs:(ocidFilePathURLArrayM) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidConfig) completionHandler:(missing value)
end open

##############################
####アプリケーションのURLを取得する
##############################
to doGetAppURL(arg_strBundleID)
  set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
  ##バンドルからアプリケーションのURLを取得
  set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
  if ocidAppBundle ≠ (missing value) then
    set ocidAppPathURL to ocidAppBundle's bundleURL()
  else if ocidAppBundle = (missing value) then
    set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
  end if
  ##予備(アプリケーションのURL)
  if ocidAppPathURL = (missing value) then
    tell application "Finder"
      try
set aliasAppApth to (application file id strBundleID) as alias
set strAppPath to POSIX path of aliasAppApth as text
set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
set strAppPath to strAppPathStr's stringByStandardizingPath()
set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
      on error
return "アプリケーションが見つかりませんでした"
      end try
    end tell
  end if
return ocidAppPathURL
end doGetAppURL
##############################
##アプリケーションが
##OPEN可能なUTIリストを取得する
##############################
to doGetUTI(arg_ocidAppPathURL)
  set ocidAppPathURL to arg_ocidAppPathURL
  ###Plistのパス
  set ocidPlistPathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
  set ocidDocTypeArray to ocidPlistDict's objectForKey:"CFBundleDocumentTypes"
  if ocidDocTypeArray = (missing value) then
    set strOutPutText to "missing value" as text
  else
    ####リストにする
    set listUTl to {} as list
    ###対応ドキュメントタイプをリストにしていく
    repeat with itemDocTypeArray in ocidDocTypeArray
      set listContentTypes to (itemDocTypeArray's objectForKey:"LSItemContentTypes")
      if listContentTypes = (missing value) then
###拡張子の指定のみの場合
set ocidExtension to (itemDocTypeArray's objectForKey:"CFBundleTypeExtensions")
set strClassName to ocidExtension's className() as text
repeat with itemExtension in ocidExtension
set strExtension to itemExtension as text
set ocidContentTypes to (refMe's UTType's typeWithFilenameExtension:(strExtension))
set strContentTypes to ocidContentTypes's identifier() as text
set strContentTypes to ("" & strContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      else
repeat with itemContentTypes in listContentTypes
set strContentTypes to ("" & itemContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      end if
    end repeat
  end if
return listUTl
end doGetUTI

|

[Preview]別ウィンドウで開く(setCreatesNewApplicationInstance)

『出来る』ってだけで、あまり推奨される方法では無いかな

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

#!/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 "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

property strBundleID : "com.apple.Preview"

set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
##バンドルからアプリケーションのURLを取得
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
##予備(アプリケーションのURL)
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
      set strAppPath to POSIX path of aliasAppApth as text
      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
      set strAppPath to strAppPathStr's stringByStandardizingPath()
      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
end if

###ファイルA
set strFilePath to "/System/Library/Templates/Data/Library/User Pictures/Sports/8ball.heic"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathAURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)

###新規インスタンスで開く設定
set ocidConfig to refMe's NSWorkspaceOpenConfiguration's configuration()
ocidConfig's setActivates:(true)
ocidConfig's setAddsToRecentItems:(false)
ocidConfig's setCreatesNewApplicationInstance:(false)
###ファイルAを開く
appSharedWorkspace's openURLs:({ocidFilePathAURL}) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidConfig) completionHandler:(missing value)

###ファイルB
set strFilePath to "/System/Library/Templates/Data/Library/User Pictures/Sports/Target.heic"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathBURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
###ファイルBを開く
appSharedWorkspace's openURLs:({ocidFilePathBURL}) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidConfig) completionHandler:(missing value)




|

画像を左右に分割する


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

#!/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
property strBundleID : "com.apple.Preview"


#############################################
### 設定項目
###Falseにすると元画像の左右半分 trueはオフセット有り
set numB5 to true as boolean

##############################
#####スクリプトメニューから実行させない
##############################
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder"
    set aliasPathToMe to path to me as alias
    tell application "Script Editor"
      open aliasPathToMe
    end tell
return "中止しました"
  end tell
else
  tell current application
    activate
  end tell
end if
######################################
##プレビューで開いているファイルを全部閉じる
######################################
####終了させてから処理させる
tell application id strBundleID
  set numCntWindow to (count of every window) as integer
end tell
if numCntWindow = 0 then
  tell application id strBundleID
    quit
  end tell
else
  tell application id strBundleID
    close (every window)
    quit
  end tell
end if
####プレビューの半ゾンビ化対策
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
end repeat
######################################
##ファイル選択
######################################
set listUTI to doGetUTI()
###ダイアログ
tell application "Finder"
  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
set strUTI to {"public.png", "public.jpeg"}
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 multiple selections allowed without showing package contents and invisibles) as list

######################################
##保存先
######################################
tell application "Finder"
  set aliasContainerDirPath to container of (item 1 of listAliasFilePath) as alias
  set aliasDefaultLocation to container of aliasContainerDirPath as alias
end tell
###
set strMes to "保存先フォルダを選んでください" as text
set strPrompt to "保存先フォルダを選択してください" as text
set aliasResponse to (choose folder strMes with prompt strPrompt default location aliasDefaultLocation without multiple selections allowed, invisibles and showing package contents) as alias
set strSaveDirPath to POSIX path of aliasResponse as text
set ocidSaveDirPathStr to refMe's NSString's stringWithString:(strSaveDirPath)
set ocidSaveDirPath to ocidSaveDirPathStr's stringByStandardizingPath()
set ocidSaveDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveDirPath) isDirectory:true)

######################################
##並び替え用にArrayにする
######################################
set ocidFileURLArrayM to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
repeat with itemAliasFilePath in listAliasFilePath
  set aliasFilePath to itemAliasFilePath 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:false)
(ocidFileURLArrayM's addObject:(ocidFilePathURL))
end repeat
###並び替え正順
set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
(ocidFileURLArrayM's sortUsingDescriptors:{ocidSortDescriptor})

######################################
##名前順に処理
######################################
set numCntFileNo to 1 as integer
repeat with itemFileURL in ocidFileURLArrayM
  ####入力URLから保存先URLを作成
  set listResourceValue to (itemFileURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))
  set ocidContentType to (item 2 of listResourceValue)
  set ocidFileExtension to (ocidContentType's preferredFilenameExtension())
  set strUTItype to ocidContentType's identifier() as text
  set ocidFileName to itemFileURL's lastPathComponent()
  set ocidBaseFileName to ocidFileName's stringByDeletingPathExtension()
  
  #####################################
  ## 本処理
  #####################################
  ###画像読み込み
  set ocidImageData to (refMe's NSImage's alloc()'s initWithContentsOfURL:(itemFileURL))
  ###中間ファイルとしてのTIFFに変換
  set ocidOsDispatchData to ocidImageData's TIFFRepresentation()
  ###元データとしてのBmpImageRep
  set ocidBmpImageRep to (refMe's NSBitmapImageRep's imageRepWithData:(ocidOsDispatchData))
  #########################
  ###画像のサイズ
  set ocidImageSize to ocidImageData's |size|()
  set numNewImageW to ((width of ocidImageSize) / 2)
  set numNewImageH to (height of ocidImageSize)
  ###画像のピクセル
  set ocidImageRepArray to ocidImageData's representations()
  set ocidImageRep to (ocidImageRepArray's objectAtIndex:0)
  set numPixelsWidth to ocidImageRep's pixelsWide()
  set numPixelsHeight to ocidImageRep's pixelsHigh()
  ###解像度
  set numResolution to ((numPixelsWidth / (width of ocidImageSize)) * 72) as integer
  ###左右のオフセット
  if numB5 is true then
    ## 画像の縦サイズから横サイズを出す 0.7037はB5サイズ
    set numNewPixelsWidth to (numPixelsHeight * 0.7037) as integer
    ###
    set numOffSet to ((numPixelsWidth / 2) - numNewPixelsWidth) as integer
  else
    ###読み込んだ画像の半分の幅=出力画像サイズW
    set numNewPixelsWidth to numPixelsWidth / 2 as integer
    set numOffSet to 0 as integer
  end if
  #########################
  ###左右の保存する画像生成
  ##右
  set ocidNewImageRepR to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numNewPixelsWidth) pixelsHigh:(numPixelsHeight) bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(refMe's NSCalibratedRGBColorSpace) bitmapFormat:(refMe's NSAlphaFirstBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
  ##左
  set ocidNewImageRepL to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numNewPixelsWidth) pixelsHigh:(numPixelsHeight) bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(refMe's NSCalibratedRGBColorSpace) bitmapFormat:(refMe's NSAlphaFirstBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
  ############################################
  ####処理開始 右から R
  ############################################
  set ocidGraphicsContext to refMe's NSGraphicsContext
ocidGraphicsContext's saveGraphicsState()
(ocidGraphicsContext's setCurrentContext:(ocidGraphicsContext's graphicsContextWithBitmapImageRep:(ocidNewImageRepR)))
  ####解像度入れた画像の合成位置
  set numSetImageSizeW to (numResolution / 72) * numNewImageW as integer
  set numSetImageSizeH to (numResolution / 72) * numNewImageH as integer
  ###仕上がり寸法RECT
  set ocidImageRepRect to {origin:{x:0, y:0}, |size|:{width:(numSetImageSizeW), height:(numSetImageSizeH)}}
  ###元データの右側のRECT
  set ocidImageRextR to {origin:{x:(numNewImageW), y:0}, |size|:{width:(numNewImageW), height:(numNewImageH)}}
(ocidBmpImageRep's drawInRect:(ocidImageRepRect) fromRect:(ocidImageRextR) operation:(refMe's NSCompositeSourceOver) fraction:1.0 respectFlipped:false hints:(missing value))
  ####処理終了
ocidGraphicsContext's restoreGraphicsState()
  if strUTItype is "public.jpeg" then
    ####JPEGデータに変換して
    set ocidInlineImageData to (ocidNewImageRepR's representationUsingType:(refMe's NSJPEGFileType) |properties|:{NSImageCompressionFactor:0.9, NSImageProgressive:false})
  else if strUTItype is "public.png" then
    set ocidInlineImageData to (ocidNewImageRepR's representationUsingType:(refMe's NSPNGFileType) |properties|:{NSImageInterlaced:true})
  end if
  ####保存  右から
  ###ファイル名連番 ゼロサプレス4桁
  set strZeroSup to "0000" as text
  set strSeroSup to (strZeroSup & (numCntFileNo as text)) as text
  set strSeroSup to (text -4 through -1 of strSeroSup) as text
  set strSaveFileName to (strSeroSup & "_" & ocidBaseFileName) as text
    ###ディレクトリにファイル名
  set ocidSaveFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName))
    ##パスに拡張子
  set ocidSaveFilePathURL to (ocidSaveFilePathURL's URLByAppendingPathExtension:(ocidFileExtension))
  set numCntFileNo to numCntFileNo + 1 as integer
  ##保存
  set listDone to (ocidInlineImageData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference))
  ############################################
  ####処理開始 左 L
  ############################################
  set ocidGraphicsContext to refMe's NSGraphicsContext
ocidGraphicsContext's saveGraphicsState()
(ocidGraphicsContext's setCurrentContext:(ocidGraphicsContext's graphicsContextWithBitmapImageRep:(ocidNewImageRepL)))
  ####解像度入れた画像の合成位置
  set numSetImageSizeW to (numResolution / 72) * numNewImageW as integer
  set numSetImageSizeH to (numResolution / 72) * numNewImageH as integer
  ###仕上がり寸法RECT
  set ocidImageRepRect to {origin:{x:(-numOffSet), y:0}, |size|:{width:(numSetImageSizeW), height:(numSetImageSizeH)}}
  ###元データの左側のRECT
  set ocidImageRextL to {origin:{x:(0), y:0}, |size|:{width:(numNewImageW), height:(numNewImageH)}}
(ocidBmpImageRep's drawInRect:(ocidImageRepRect) fromRect:(ocidImageRextL) operation:(refMe's NSCompositeSourceOver) fraction:1.0 respectFlipped:false hints:(missing value))
  ####処理終了
ocidGraphicsContext's restoreGraphicsState()
  if strUTItype is "public.jpeg" then
    ####JPEGデータに変換して
    set ocidInlineImageData to (ocidNewImageRepL's representationUsingType:(refMe's NSJPEGFileType) |properties|:{NSImageCompressionFactor:0.9, NSImageProgressive:false})
  else if strUTItype is "public.png" then
    set ocidInlineImageData to (ocidNewImageRepL's representationUsingType:(refMe's NSPNGFileType) |properties|:{NSImageInterlaced:true})
  end if
  ###ファイル名連番 ゼロサプレス4桁
  set strZeroSup to "0000" as text
  set strSeroSup to (strZeroSup & (numCntFileNo as text)) as text
  set strSeroSup to (text -4 through -1 of strSeroSup) as text
  set strSaveFileName to (strSeroSup & "_" & ocidBaseFileName) as text
  ###ディレクトリにファイル名
  set ocidSaveFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName))
  ##パスに拡張子
  set ocidSaveFilePathURL to (ocidSaveFilePathURL's URLByAppendingPathExtension:(ocidFileExtension))
  ####保存
  set numCntFileNo to numCntFileNo + 1 as integer
  set listDone to (ocidInlineImageData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference))
  
end repeat

return
######################################
##対象UTI
######################################

to doGetUTI()
  ###アプリケーションのURLを取得
  ###NSバンドルをUTIから取得
  set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
  if ocidAppBundle = (missing value) then
    ###NSバンドル取得できなかった場合
    set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
    set ocidAppPathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
  else
    set ocidAppPathURL to ocidAppBundle's bundleURL()
  end if
  ###Plistのパス
  set ocidPlistPathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
  set ocidDocTypeArray to ocidPlistDict's objectForKey:"CFBundleDocumentTypes"
  if ocidDocTypeArray = (missing value) then
    set strOutPutText to "missing value" as text
  else
    ####リストにする
    set listUTl to {} as list
    ###対応ドキュメントタイプをリストにしていく
    repeat with itemDocTypeArray in ocidDocTypeArray
      set listContentTypes to (itemDocTypeArray's objectForKey:"LSItemContentTypes")
      if listContentTypes = (missing value) then
###拡張子の指定のみの場合
set ocidExtension to (itemDocTypeArray's objectForKey:"CFBundleTypeExtensions")
set strClassName to ocidExtension's className() as text
repeat with itemExtension in ocidExtension
set strExtension to itemExtension as text
set ocidContentTypes to (refMe's UTType's typeWithFilenameExtension:(strExtension))
set strContentTypes to ocidContentTypes's identifier() as text
set strContentTypes to ("" & strContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      else
repeat with itemContentTypes in listContentTypes
set strContentTypes to ("" & itemContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      end if
    end repeat
  end if
return listUTl
end doGetUTI










|

[com.apple.Preview]プレビューで画像の入っているフォルダを開く(ファイル名順)

プレビューで開けないファイルを除外する処理を入れた

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

#!/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 scripting additions

property refMe : a reference to current application
property strBundleID : "com.apple.Preview"


on run
  set aliasDefaultLocation to (path to desktop from user domain) as alias
  set strPromptText to "画像が入ったフォルダをえらんでください"
  set strMesText to "画像が入ったフォルダをえらんでください"
  try
    set listFolderPath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
open listFolderPath
end run


on open listFolderPath
  tell application "Finder"
    set strKind to (kind of (item 1 of listFolderPath)) as text
  end tell
  if strKind is not "フォルダ" then
return "フォルダ以外は処理しない"
  end if
  
  ####終了させてから処理させる
  tell application id strBundleID
    set numCntWindow to (count of every window) as integer
  end tell
  if numCntWindow = 0 then
    tell application id strBundleID
      quit
    end tell
  else
    tell application id strBundleID
      close (every window)
      quit
    end tell
  end if
  ####プレビューの半ゾンビ化対策
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
  ###enumeratorAtURL用のBoolean用
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  
  ################################
  ####フォルダの数だけ繰り返し
  ################################
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLAllArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ###まずは全部のURLをArrayに入れる
  repeat with itemFolderPath in listFolderPath
    ######パス フォルダのエイリアス
    set aliasDirPath to itemFolderPath as alias
    ###UNIXパスにして
    set strDirPath to POSIX path of aliasDirPath as text
    ###Stringsに
    set ocidDirPath to (refMe's NSString's stringWithString:strDirPath)
    ###パス確定させて
    set ocidDirPath to ocidDirPath's stringByStandardizingPath
    ###NSURLに
    set ocidDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidDirPath isDirectory:true)
    ##################################
    ##プロパティ
    set ocidPropertieKey to {refMe's NSURLPathKey, refMe's NSURLIsRegularFileKey, refMe's NSURLContentTypeKey}
    ##オプション(隠しファイルは含まない)
    set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
    ####ディレクトリのコンテツを収集(最下層まで)
    set ocidEmuDict to (appFileManager's enumeratorAtURL:ocidDirPathURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption errorHandler:(reference))
    ###戻り値をリストに格納
    set ocidEmuFileURLArray to ocidEmuDict's allObjects()
(ocidFilePathURLAllArray's addObjectsFromArray:ocidEmuFileURLArray)
  end repeat
  ################################
  ####必要なファイルだけのArrayにする
  ################################
  set ocidFilePathURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ####URLの数だけ繰り返し
  repeat with itemFilePathURL in ocidFilePathURLAllArray
    ###################不要なファイルをゴミ箱に入れちゃう
    ####拡張子取って
    set ocidExtension to itemFilePathURL's pathExtension()
    ###URLファイル削除
    if (ocidExtension as text) is "url" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###WindowのサムネイルDB削除
    else if (ocidExtension as text) is "db" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###webloc削除
    else if (ocidExtension as text) is "webloc" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
    else
      ####URLをforKeyで取り出し
      set listResult to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsRegularFileKey) |error|:(reference))
      ###リストからNSURLIsRegularFileKeyのBOOLを取り出し
      set boolIsRegularFileKey to item 2 of listResult
      ####ファイルのみを(ディレクトリやリンボリックリンクは含まない)
      if boolIsRegularFileKey is ocidTrue then
####リストにする
(ocidFilePathURLArray's addObject:(itemFilePathURL))
      end if
    end if
  end repeat
  log ocidFilePathURLArray as list
  ################################
  ####ファイルタイプのチェックをする
  ################################
  set listUTI to doGetUTI() as list
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLArrayM to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  repeat with itemFilePathURL in ocidFilePathURLArray
    ####UTIの取得
    set listResourceValue to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))
    set ocidContentType to (item 2 of listResourceValue)
    set strUTI to (ocidContentType's identifier) as text
    if listUTI contains strUTI then
(ocidFilePathURLArrayM's addObject:(itemFilePathURL))
    end if
  end repeat
  
  log ocidFilePathURLArrayM as list
  ##############################
  ####並び替え並び替え
  ##############################
  ## set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
  set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"compare:")
  
(ocidFilePathURLArrayM's sortUsingDescriptors:{ocidSortDescriptor})
  
  ##############################
  ####エリアスリストにして
  ##############################
  ###空のリスト=プレヴューに渡すため
  set listAliasPath to {} as list
  ###並び変わったファイルパスを順番に
  repeat with itemFilePathURL in ocidFilePathURLArrayM
    ###エイリアスにして
    set aliasFilePath to (itemFilePathURL's absoluteURL()) as alias
    ####リストに格納していく
    copy aliasFilePath to end of listAliasPath
  end repeat
  if listAliasPath is {} then
return "Openできる書類はありませんでした"
  end if
  ##############################
  ####起動
  ##############################
  try
    tell application id "com.apple.Preview" to launch
  on error
    tell application id "com.apple.Preview" to activate
  end try
  ##############################
  ####プレビューで開く
  ##############################
  tell application id "com.apple.Preview"
    activate
    set numWindow to count of window
    if numWindow = 0 then
      try
open listAliasPath
      on error
log "ここでエラー"
      end try
    else
      ####新しいウィンドで開く方法がわからん
      ####新しいインスタンス生成すれば良いのかな
open listAliasPath
    end if
  end tell
  
end open





to doGetUTI()
  ###アプリケーションのURLを取得
  ###NSバンドルをUTIから取得
  set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
  if ocidAppBundle = (missing value) then
    ###NSバンドル取得できなかった場合
    set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
    set ocidAppPathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
  else
    set ocidAppPathURL to ocidAppBundle's bundleURL()
  end if
  ###Plistのパス
  set ocidPlistPathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
  set ocidDocTypeArray to ocidPlistDict's objectForKey:"CFBundleDocumentTypes"
  if ocidDocTypeArray = (missing value) then
    set strOutPutText to "missing value" as text
  else
    ####リストにする
    set listUTl to {} as list
    ###対応ドキュメントタイプをリストにしていく
    repeat with itemDocTypeArray in ocidDocTypeArray
      set listContentTypes to (itemDocTypeArray's objectForKey:"LSItemContentTypes")
      if listContentTypes = (missing value) then
###拡張子の指定のみの場合
set ocidExtension to (itemDocTypeArray's objectForKey:"CFBundleTypeExtensions")
set strClassName to ocidExtension's className() as text
repeat with itemExtension in ocidExtension
set strExtension to itemExtension as text
set ocidContentTypes to (refMe's UTType's typeWithFilenameExtension:(strExtension))
set strContentTypes to ocidContentTypes's identifier() as text
set strContentTypes to ("" & strContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      else
repeat with itemContentTypes in listContentTypes
set strContentTypes to ("" & itemContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      end if
    end repeat
  end if
return listUTl
end doGetUTI

|

[Preview]画像フォルダを開く

ダウンロード -画像フォルダを開く.app.zip


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

#!/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 scripting additions

property refMe : a reference to current application


on run
  set aliasDefaultLocation to (path to desktop from user domain) as alias
  set strPromptText to "画像が入ったフォルダをえらんでください"
  set strMesText to "画像が入ったフォルダをえらんでください"
  try
    set listFolderPath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
open listFolderPath
end run


on open listFolderPath
  ####プレビューの半ゾンビ化対策
  tell application id "com.apple.Preview"
    set numCntWindow to (count of every window) as integer
  end tell
  ####終了させてから処理させる
  if numCntWindow = 0 then
    tell application id "com.apple.Preview"
      quit
    end tell
  else
    tell application id "com.apple.Preview"
      close (every window)
      ## close (every document)
      quit
    end tell
  end if
  
  ###enumeratorAtURL用のBoolean用
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  
  ################################
  ####フォルダの数だけ繰り返し
  ################################
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLAllArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ###まずは全部のURLをArrayに入れる
  repeat with itemFolderPath in listFolderPath
    ######パス フォルダのエイリアス
    set aliasDirPath to itemFolderPath as alias
    ###UNIXパスにして
    set strDirPath to POSIX path of aliasDirPath as text
    ###Stringsに
    set ocidDirPath to (refMe's NSString's stringWithString:strDirPath)
    ###パス確定させて
    set ocidDirPath to ocidDirPath's stringByStandardizingPath
    ###NSURLに
    set ocidDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidDirPath isDirectory:true)
    ##################################
    ##プロパティ
    set ocidPropertieKey to {refMe's NSURLPathKey, refMe's NSURLIsRegularFileKey}
    ##オプション(隠しファイルは含まない)
    set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
    ####ディレクトリのコンテツを収集(最下層まで)
    set ocidEmuDict to (appFileManager's enumeratorAtURL:ocidDirPathURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption errorHandler:(reference))
    ###戻り値をリストに格納
    set ocidEmuFileURLArray to ocidEmuDict's allObjects()
(ocidFilePathURLAllArray's addObjectsFromArray:ocidEmuFileURLArray)
  end repeat
  ################################
  ####必要なファイルだけのArrayにする
  ################################
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ####URLの数だけ繰り返し
  repeat with itemFilePathURL in ocidFilePathURLAllArray
    ###################不要なファイルをゴミ箱に入れちゃう
    ####拡張子取って
    set ocidExtension to itemFilePathURL's pathExtension()
    ###URLファイル削除
    if (ocidExtension as text) is "url" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###WindowのサムネイルDB削除
    else if (ocidExtension as text) is "db" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###webloc削除
    else if (ocidExtension as text) is "webloc" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
    else
      ####URLをforKeyで取り出し
      set listResult to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsRegularFileKey) |error|:(reference))
      ###リストからNSURLIsRegularFileKeyのBOOLを取り出し
      set boolIsRegularFileKey to item 2 of listResult
      ####ファイルのみを(ディレクトリやリンボリックリンクは含まない)
      if boolIsRegularFileKey is ocidTrue then
####リストにする
(ocidFilePathURLArray's addObject:(itemFilePathURL))
      end if
    end if
  end repeat
  
  ##############################
  ####並び替え並び替え
  ##############################
  ## set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
  set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"compare:")
  
(ocidFilePathURLArray's sortUsingDescriptors:{ocidSortDescriptor})
  
  ##############################
  ####エリアスリストにして
  ##############################
  ###空のリスト=プレヴューに渡すため
  set listAliasPath to {} as list
  ###並び変わったファイルパスを順番に
  repeat with itemFilePathURL in ocidFilePathURLArray
    ###エイリアスにして
    set aliasFilePath to (itemFilePathURL's absoluteURL()) as alias
    ####リストに格納していく
    copy aliasFilePath to end of listAliasPath
  end repeat
  ##############################
  ####起動
  ##############################
  tell application id "com.apple.Preview"
    launch
  end tell
  ##############################
  ####プレビューで開く
  ##############################
  tell application id "com.apple.Preview"
    activate
    set numWindow to count of window
    if numWindow = 0 then
      try
open listAliasPath
      on error
log "ここでエラー"
      end try
    else
      ####新しいウィンドで開く方法がわからん
      ####新しいインスタンス生成すれば良いのかな
open listAliasPath
    end if
  end tell
  
end open


|

[画像フォルダ]ファイル名順に開く(修正版)

ダウンロード - open_image_folder.zip


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

#!/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 scripting additions

property refMe : a reference to current application


on run
  set aliasDefaultLocation to (path to desktop from user domain) as alias
  set strPromptText to "フォルダをえらんでください"
  set strMesText to "画像が入ったフォルダをえらんでください"
  try
    set listFolderPath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
open listFolderPath
end run


on open listFolderPath
  ####プレビューの半ゾンビ化対策
  tell application id "com.apple.Preview"
    set numCntWindow to count of window
  end tell
  ####終了させてから処理させる
  if numCntWindow = 0 then
    tell application id "com.apple.Preview"
      quit
    end tell
  end if
  
  ###enumeratorAtURL用のBoolean用
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  
  ################################
  ####フォルダの数だけ繰り返し
  ################################
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLAllArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ###まずは全部のURLをArrayに入れる
  repeat with itemFolderPath in listFolderPath
    ######パス フォルダのエイリアス
    set aliasDirPath to itemFolderPath as alias
    ###UNIXパスにして
    set strDirPath to POSIX path of aliasDirPath as text
    ###Stringsに
    set ocidDirPath to (refMe's NSString's stringWithString:strDirPath)
    ###パス確定させて
    set ocidDirPath to ocidDirPath's stringByStandardizingPath
    ###NSURLに
    set ocidDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidDirPath isDirectory:true)
    ##################################
    ##プロパティ
    set ocidPropertieKey to {refMe's NSURLPathKey, refMe's NSURLIsRegularFileKey}
    ##オプション(隠しファイルは含まない)
    set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
    ####ディレクトリのコンテツを収集(最下層まで)
    set ocidEmuDict to (appFileManager's enumeratorAtURL:ocidDirPathURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption errorHandler:(reference))
    ###戻り値をリストに格納
    set ocidEmuFileURLArray to ocidEmuDict's allObjects()
(ocidFilePathURLAllArray's addObjectsFromArray:ocidEmuFileURLArray)
  end repeat
  ################################
  ####必要なファイルだけのArrayにする
  ################################
  ###ファイルURLのみを格納するリスト
  set ocidFilePathURLArray to (refMe's NSMutableArray's alloc()'s initWithCapacity:0)
  ####URLの数だけ繰り返し
  repeat with itemFilePathURL in ocidFilePathURLAllArray
    ###################不要なファイルをゴミ箱に入れちゃう
    ####拡張子取って
    set ocidExtension to itemFilePathURL's pathExtension()
    ###URLファイル削除
    if (ocidExtension as text) is "url" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###WindowのサムネイルDB削除
    else if (ocidExtension as text) is "db" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
      ###webloc削除
    else if (ocidExtension as text) is "webloc" then
      set listResult to (appFileManager's trashItemAtURL:(itemFilePathURL) resultingItemURL:(missing value) |error|:(reference))
    else
      ####URLをforKeyで取り出し
      set listResult to (itemFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsRegularFileKey) |error|:(reference))
      ###リストからNSURLIsRegularFileKeyのBOOLを取り出し
      set boolIsRegularFileKey to item 2 of listResult
      ####ファイルのみを(ディレクトリやリンボリックリンクは含まない)
      if boolIsRegularFileKey is ocidTrue then
####リストにする
(ocidFilePathURLArray's addObject:(itemFilePathURL))
      end if
    end if
  end repeat
  
  ##############################
  ####並び替え並び替え
  ##############################
  set ocidSortDescriptor to (refMe's NSSortDescriptor's sortDescriptorWithKey:"absoluteString" ascending:(true) selector:"localizedStandardCompare:")
(ocidFilePathURLArray's sortUsingDescriptors:{ocidSortDescriptor})
  
  ##############################
  ####エリアスリストにして
  ##############################
  ###空のリスト=プレヴューに渡すため
  set listAliasPath to {} as list
  ###並び変わったファイルパスを順番に
  repeat with itemFilePathURL in ocidFilePathURLArray
    ###エイリアスにして
    set aliasFilePath to (itemFilePathURL's absoluteURL()) as alias
    ####リストに格納していく
    copy aliasFilePath to end of listAliasPath
  end repeat
  ##############################
  ####起動
  ##############################
  tell application id "com.apple.Preview"
    launch
  end tell
  ##############################
  ####プレビューで開く
  ##############################
  tell application id "com.apple.Preview"
    activate
    set numWindow to count of window
    if numWindow = 0 then
      try
open listAliasPath
      on error
log "ここでエラー"
      end try
    else
      ####新しいウィンドで開く方法がわからん
open listAliasPath
    end if
  end tell
  
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