クリエイター手抜きプロジェクト[344]Illustrator CS5+Mac OS X編 Spotlight検索できるようにする
── 古籏一浩 ──

投稿:  著者:


しばらく自動海外、じゃなくて自動化以外のネタが多かったので、いったん自動化ネタに戻るということで。

Mac OS Xでは、Spotlightのおかげで文章中に存在する語句を簡単に検索することができます。語句に限らず文でも検索できます。単なるテキストだけでなく、PDF内にある文字も検索されるので便利です。

しかし、Illustratorで作成したAIファイルと、EPSファイルに関しては検索されません。Illustratorで作成したデータが、常にPDFで保存するわけではないのでAI、EPSファイル内にある文字を探すのは手間がかかります。

AI、EPSファイルを検索にひっかかるようにするには、一度開いてPDFで保存します。これだけでSpotlightですぐに検索されるようになります。

以下のスクリプトは、選択したフォルダ内にあるAIファイルとEPSファイルを開いて、同じ階層にPDFとして保存します。ディスク容量が少ない場合には、PDFの分だけディスク容量を消費するので、あまりよい方法ではありません。





(function(){
var aiList = getAllFiles(["*.ai", "*.eps"]);
for(var i=0; i<aiList.length; i++){
//$.writeln(aiList[i].fullName);
app.open(aiList[i]);
var opt = new PDFSaveOptions();
opt.trimMarks = false; // トリムマークなし
opt.compatibility = PDFCompatibility.ACROBAT8; // Acrobat 8
opt.generateThumbnails = false; // サムネールなし
var saveFile = new File(aiList[i].fullName+".pdf");
activeDocument.saveAs(saveFile, opt);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
})();
// File Library
function getAllFiles(fileTypes, basePath,options){
options = options || {};
if(!basePath){
basePath = Folder.selectDialog("フォルダを選択してください");
if (!basePath){ return; } // キャンセルされた場合は処理しない
}
var allList = [];
// パラメータが文字の場合
if (typeof(fileTypes) == "string"){
getFileList(new Folder(basePath), fileTypes);
return toJapanese(allList, options.japanese);
}
// パラメータが配列の場合
if (fileTypes.push){
for(var i=0; i<fileTypes.length; i++){
getFileList(new Folder(basePath), fileTypes[i]);
}
return toJapanese(allList, options.japanese);
}
function getFileList(currentFolder, fileType){
var fileList = currentFolder.getFiles(fileType);
var fileList2 = currentFolder.getFiles("*"); // Sub Folder
allList = allList.concat(fileList);
for(var i=0; i<fileList2.length; i++){
if (fileList2[i].getFiles){
if (fileList2[i].name.charAt(0) == "."){ continue; }
getFileList(fileList2[i], fileType); // フォルダがある限り繰り返し
}
}
}
// 日本語に変換(nameJ, fullNameJ)
function toJapanese(fileList, flag){
if (!flag){ return fileList; }
for(var i=0; i<fileList.length; i++){
fileList[i].nameJ = File.decode(fileList[i].name);
fileList[i].fullNameJ = File.decode(fileList[i].fullName);
}
return fileList;
}
}

ちなみに、Photoshopでは入力したテキストはSpotlight検索できるようになるので、上記のようなスクリプトは不要です。。

【古籏一浩】openspc@alpha.ocn.ne.jp
< http://www.openspc2.org/
>

先週の川合和史さんのアニソンネタ。13曲の10倍くらいなら勝負しても勝てそうな気がするなあ。

映像のRAWファイルをいじってみた。一眼レフのカメラだと普通にRAWファイル保存できるけど、映像でRAWだとそれができるカメラは限定されます。で、とりあえず映像のRAWファイルを扱えるアプリの使い方のページ作成。それから、Adobe Premiere CS6のページも項目を追加しておきました。

・REDCINE-X PRO 使い方辞典
< http://www.openspc2.org/reibun/RED/REDCINE-X/17.2/
>

・Adobe Premiere CS6自動化作戦
< http://www.openspc2.org/book/PremiereCS6/
>

・Adobe Premiere Pro CS6使い方辞典
< http://www.openspc2.org/reibun/PremiereCS6/
>

・Kindle Fire HD使い方辞典
< http://www.openspc2.org/reibun/Kindle/Fire_HD/
>

・Nexus 7(アンドロイドタブレット)使い方辞典
< http://www.openspc2.org/reibun/Android/Nexus7/
>

・iPad mini(アイパッドミニ)使い方辞典
< http://www.openspc2.org/reibun/iPad/mini/2012/
>

・JavaScript逆引きハンドブック
< http://www.amazon.co.jp/dp/4863541082
>

・改訂5版JavaScriptポケットリファレンス
< http://www.amazon.co.jp/dp/4774148199
>

・ハイビジョン映像素材集
< http://www.openspc2.org/HDTV/
>

・クリエイター手抜きプロジェクト
< http://www.openspc2.org/projectX/
>

・Adobe Illustrator CS3 + JavaScript 自動化サンプル集
< http://www.openspc2.org/book/PDF/Adobe_Illustrator_CS3_JavaScript_Book/
>
吉田印刷所の「印刷の泉」でも購入できるようになりました。