
AS記法 MakePDF ファイル指定
【Safari・FireFox用Script Editorで開く】 |
| ソース | |
|---|---|
| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 004 | (* |
| 005 | |
| 006 | com.cocolog-nifty.quicktimer.icefloe *) |
| 007 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 008 | use AppleScript version "2.8" |
| 009 | use scripting additions |
| 010 | |
| 011 | |
| 012 | ######################## |
| 013 | # RUN |
| 014 | on run |
| 015 | #on run {listAliasFilePath} |
| 016 | |
| 017 | ######################## |
| 018 | #Dialog |
| 019 | set strMsg to ("Choose file") as text |
| 020 | set strPrompt to ("Choose file" & return & "multiple selections allowed") as text |
| 021 | set aliasDesktopDirPath to (path to desktop from user domain) as alias |
| 022 | set listUTI to {"public.item"} as list |
| 023 | try |
| 024 | tell application "Finder" |
| 025 | #Finderから呼び出すことでスクリプトアプリケーションになってもダイアログがマルチリンガルになります |
| 026 | #By calling from Finder, the dialog becomes multilingual even if it becomes a script application. |
| 027 | tell application "SystemUIServer" |
| 028 | activate |
| 029 | set listAliasFilePath to (choose file strMsg with prompt strPrompt default location aliasDesktopDirPath of type listUTI with invisibles and multiple selections allowed without showing package contents) as list |
| 030 | end tell |
| 031 | end tell |
| 032 | on error strErrMes number numErrNo |
| 033 | log strErrMes & numErrNo |
| 034 | return false |
| 035 | end try |
| 036 | |
| 037 | set boolDone to (open listAliasFilePath) as boolean |
| 038 | return boolDone |
| 039 | end run |
| 040 | |
| 041 | ######################## |
| 042 | # OPEN |
| 043 | on open listAliasFilePath |
| 044 | #次工程に回すリスト List to be transferred to the next process |
| 045 | set listImgFilePath to {} as list |
| 046 | #IMAGE UTI |
| 047 | set listImageUTI to {"public.image", "public.png", "public.tiff", "public.jpeg", "public.heic"} as list |
| 048 | |
| 049 | |
| 050 | repeat with itemAliasFilePath in listAliasFilePath |
| 051 | #エイリアス確定 Alias confirmed |
| 052 | set aliasItemFilePath to itemAliasFilePath as alias |
| 053 | #ファイルINFOを取得 Get the file INFO |
| 054 | set recordInfoFor to (info for aliasItemFilePath) as record |
| 055 | #フォルダ判定 |
| 056 | set boolIsDir to (folder of recordInfoFor) as boolean |
| 057 | |
| 058 | if boolIsDir is true then |
| 059 | #フォルダなら IS DIR |
| 060 | set boolDone to doFolderJon(aliasItemFilePath) as boolean |
| 061 | |
| 062 | else if boolIsDir is false then |
| 063 | #ファイルなら IS FILE |
| 064 | set strUTI to (type identifier of recordInfoFor) as text |
| 065 | #UTIが対象ファイルなら |
| 066 | if listImageUTI contains strUTI then |
| 067 | #エイリアスリストに追加 |
| 068 | set beginning of listImgFilePath to aliasItemFilePath |
| 069 | end if |
| 070 | end if |
| 071 | |
| 072 | end repeat |
| 073 | |
| 074 | #本処理に回す Turn to this processing |
| 075 | set boolDone to doOpenFileList(listImgFilePath) |
| 076 | |
| 077 | return true |
| 078 | end open |
| 079 | |
| 080 | |
| 081 | ######################## |
| 082 | #Do Folder JOB |
| 083 | to doFolderJon(argAliasFilePath) |
| 084 | |
| 085 | return false |
| 086 | end doFolderJon |
| 087 | |
| 088 | ######################## |
| 089 | #OPEN MakePDF2IMAGE |
| 090 | to doOpenFileList(listImgFilePath) |
| 091 | tell application "Finder" |
| 092 | set listAliasImgFilePath to listImgFilePath as alias list |
| 093 | set listAliasFilePathSorted to (sort of listAliasImgFilePath by name) as alias list |
| 094 | open listAliasFilePathSorted using application file id "com.apple.MakePDF" |
| 095 | end tell |
| 096 | return true |
| 097 | end doOpenFileList |
| 098 | |
| AppleScriptで生成しました | |
