gikoha’s blog

個人的メモがわり

perl などのAppleScriptフロントエンド用

AppleScript Studioの"Run"ボタンにくっつけます

on clicked theObject
	set aFolder to choose folder with prompt "foo bar"
	set aDirectory to POSIX path of aFolder
	set CWD to resource path of main bundle as string
	tell window of theObject
		set theURL to contents of text field "theURL"
		set thePages to integer value of text field "thePages"
	end tell
	tell progress indicator 1 of window 1
		set minimum value to 0
		set maximum value to thePages
	end tell
	set enabled of theObject to false
	repeat with i from 0 to thePages
		tell progress indicator "theProgress" of window 1
			set contents to i
		end tell
		set PERL_COMMAND to CWD & "/hogehoge.pl " & (i as string) & " " & theURL
		set theScript to "cd '" & aDirectory & "'; /usr/bin/perl " & PERL_COMMAND
		do shell script theScript
	end repeat
	set enabled of theObject to true
end clicked