製品情報      ご購入      サポート      コミュニティー      会社概要(英語)      ユーザー登録
ホーム > サポート > チュートリアル > Mac OS でスクリプティング

Mac OSでスクリプティング

previous Next

バッチ変換用のスクリプト

このスクリプトは、指定されたフォルダに保存されているCanvas に読み込み可能なファイルを開き、指定する別のファイル形式に変換して保存するためのものです。大量のファイルを一気に別のファイル形式に変換したい場合には大変便利です。

-- このスクリプトはファイルを任意のCanvas™ 8でサポートされているファイル形式に変換して保存します。

tell application "Finder"

activate
set importFolder to choose folder with prompt "イメージが保存されているフォルダを選択してください。"
set exportFolder to choose folder with prompt "保存用フォルダを選択してください。"
set nFiles to count folder importFolder each file

display dialog "どの形式に変換するか番号で指定してください。" & return & return & "1=AI, 2=bmp, 3=cals, 4=Canvas, 5=CGM, 6=DCX, 7=DRW, 8=DXF, 9=EPSF, 10=Flash, 11=GIF, 12=HTML, 13=Icon, 14=IFF, 15=jpeg, 16= PCX, 17=PDF, 18=Photoshop, 19=Targa, 20=Tiff, 21=WPG" default answer ""
set userValue to (text returned of result) as real

end tell

repeat with i from 1 to nFiles

tell application "Finder"

set f to file i of importFolder
set fName to get name of f

end tell

tell application "Canvas™ 8"

activate
open (importFolder as string) & fName
if userValue is 1 then
save document 1 in (exportFolder as string) & fName & ".AI" as AI
else if userValue is 2 then
save document 1 in (exportFolder as string) & fName & ".BMP" as BMP
else if userValue is 3 then
save document 1 in (exportFolder as string) & fName & ".CAL" as CALS
else if userValue is 4 then
save document 1 in (exportFolder as string) & fName & ".CNV" as Canvas
else if userValue is 5 then
save document 1 in (exportFolder as string) & fName & ".CGM" as CGM
else if userValue is 6 then
save document 1 in (exportFolder as string) & fName & ".DCX" as DCX
else if userValue is 7 then
save document 1 in (exportFolder as string) & fName & ".DRWI" as DRW
else if userValue is 8 then
save document 1 in (exportFolder as string) & fName & ".DXF" as DXF
else if userValue is 9 then
save document 1 in (exportFolder as string) & fName & ".EPS" as EPSF with options {preview color mode:rgb mode}
else if userValue is 10 then
save document 1 in (exportFolder as string) & fName & ".SWF" as FLASH
else if userValue is 11 then
save document 1 in (exportFolder as string) & fName & ".GIF" as GIF
else if userValue is 12 then
save document 1 in (exportFolder as string) & fName & ".HTML" as HTML
else if userValue is 13 then
save document 1 in (exportFolder as string) & fName & ".ICO" as ICON
else if userValue is 14 then
save document 1 in (exportFolder as string) & fName & ".IFF" as IFF
else if userValue is 15 then
save document 1 in (exportFolder as string) & fName & ".JPG" as JPEG
else if userValue is 16 then
save document 1 in (exportFolder as string) & fName & ".PCX" as PCX
else if userValue is 17 then
save document 1 in (exportFolder as string) & fName & ".PDF" as PDF
else if userValue is 18 then
save document 1 in (exportFolder as string) & fName & ".PSD" as Photoshop
else if userValue is 19 then
save document 1 in (exportFolder as string) & fName & ".TGA" as TARGA
else if userValue is 20 then
save document 1 in (exportFolder as string) & fName & ".TIF" as TIFF
else if userValue is 21 then
save document 1 in (exportFolder as string) & fName & ".WPG" as WPG
end if
close document 1

end tell

end repeat

tell application "Canvas™ 8"

quit

end tell


Canvas 8に含まれているサンプルスクリプトを開く

バッチ変換用のスクリプトを開くには、「Batch Convert」というファイルをダブルクリックして、「Script Editor」を開きます。


備考: 含まれているスクリプトと上記のスクリプトは多少異なるところがありますが、実行される作業はほとんど同じです。

上記のスクリプトをダウンロードするには、ここを クリックしてください。

AppleScriptは、テキスト ベースなので、「Script Editor」に上記のコードテキストをコピー/ペーストすることも可能です。

  1. Script Editor を開きます。
  2. 「ファイル」メニューから「新規スクリプト」を選択します。
  3. Webブラウザに表示されている上記のコードをコピーし、Script Editorの下の欄にペーストします。
  4. <構文確認>ボタンをクリックして、ペーストしたコードが正しいかどうかチェックすることができます。
  5. 最後に、「ファイル」メニューから「別名で保存」を選択し、スクリプト名を付けて「コンパイル済みスクリプト」として保存します。


備考:
Canvas 用のスクリプトを作成および編集するには、Mac OS にAppleScript がインストールされていなければなりません。

 

次は、AppleScript のコードを見てみましょう。

    previous Next

ページ 1 | ページ 2 | ページ 3 | ページ 4 | ページ 5

製品概要 | ご購入 | サポート | コミュニティー | 会社概要(英語) | ユーザー登録

Copyright © 1995-2006 ACD Systems of America Inc.
Protected by the copyright laws of the United States and Canada and by international treaties.
法律上の注意事項 | プライバシーポリシー