Created
June 14, 2010 11:46
-
-
Save kanemu/437586 to your computer and use it in GitHub Desktop.
mi用InDesign実行スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#new | |
TM_FILEPATH=$1 | |
#スクリプトを複製 | |
#$.write、$.writelnをオーバーライド | |
echo "var file=new File(\"${TM_FILEPATH}.log\");file.encoding=\"UTF8\";file.lineFeed=\"Mac\";file.open('e'); | |
\$.write = function(){file.seek(0,2);file.write(arguments[0])}; | |
\$.writeln = function(){file.seek(0,2);file.writeln(arguments[0])};"> ${TM_FILEPATH}.tmp.jsx | |
#Scriptの内容を書き込み | |
cat $TM_FILEPATH >> ${TM_FILEPATH}.tmp.jsx | |
echo '' >> ${TM_FILEPATH}.tmp.jsx | |
#ログを閉じる行を書き込み | |
echo "file.close();" >> ${TM_FILEPATH}.tmp.jsx | |
#Scriptを1行づつ読み込んで#targetを探す | |
while read -r LINE; do | |
target=`expr "$LINE" : '^#target \{1,\}"\(.\{1,\}\)" *$'` | |
if [ "$target" != "" ]; then | |
break | |
fi | |
done < $TM_FILEPATH | |
#targetの検索結果から条件分岐して、実行するアプリを選択(CS4_JP) | |
if echo "$target" | fgrep -iq 'photoshop' ; then | |
app="/Applications/Adobe Photoshop CS3/Adobe Photoshop CS3.app" | |
run="do javascript file (fileName as POSIX file)" | |
elif echo "$target" | fgrep -iq 'illustrator' ; then | |
app="/Applications/Adobe Illustrator CS3/Adobe Illustrator.app" | |
run="do javascript file (fileName as POSIX file)" | |
else | |
app="/Applications/Adobe InDesign CS3/Adobe InDesign CS3.app" | |
run="do script file (fileName as POSIX file) language javascript" | |
fi | |
#ログファイルを作成 | |
: > ${TM_FILEPATH}.log | |
#osascriptからAppleScriptを実行 | |
osascript -e "on run argv | |
set fileName to item 1 of argv | |
tell application \"$app\" | |
$run | |
end tell | |
end run" ${TM_FILEPATH}.tmp.jsx | |
#結果を表示 | |
echo "----結果----" | |
echo `cat ${TM_FILEPATH}.log` | |
echo "----結果----" | |
#ログとスクリプトを削除 | |
rm ${TM_FILEPATH}.tmp.jsx | |
rm ${TM_FILEPATH}.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment