Blueickx Blog

Mac User Productivity & MacOS Automation

ScriptDebugger 4.5 のGetting Started Guide を見てみる

デスクトップに新しいフォルダを作る

ScriptDebugger 4.5 のメニューバーから使えるようになっているGetting Started Guideの附属スクリプトが10個くらいある。

Script 1 は下の通り。

走らせると、適当にjpeg画像を選択しろと言ってきて、選択したあとは、デスクトップに「myImageFiles」というフォルダを作成して、その中にjpeg画像100個を複製して連番を付けて格納する。

スクリプト動作テスト用の画像ファイルを作ってくれた訳だろう。肝心のGuideを、これから読むので真意はこれから。

-->> create and populate folder

-- Script 1: Make Working Folder

-->> ask user for initial jpg

set s to "Please pick a small JPEG image to be used as a model:"

set jpg to ¬

choose file with prompt s of type {"public.jpeg"} ¬

default location (path to pictures folder) without invisibles, multiple selections allowed and showing package contents

-->> check for existing folder

tell application "Finder" to exists folder "myImageFiles"

if result then

display dialog "A folder \"myImageFiles\" already exists " & ¬

¬

"on the desktop. OK to move it to the trash?" buttons {"OK", "Stop!"} default button 2

if button returned of result is not "OK" then return

tell application "Finder" to delete folder "myImageFiles"

end if

-->> create and populate folder

tell application "Finder" to make new folder ¬

with properties {name:"myImageFiles"} at desktop

set fold to result

repeat with ix from 166 to 166 + 100

tell application "Finder" to set name of (duplicate jpg to fold) ¬

to "CIMG0" & ix & ".jpg"

end repeat