20260614

AS記法 WEBページ作成 ファイル指定

AS記法 WEBページ作成 ファイル指定

NOTE記事一覧ですnote.com
 

【Safari・FireFox用Script Editorで開く】 |

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