|
macOS10.12.6 InDesignCC2015/CC2019
フォルダ名が画像名とかぶるとエラーが出ます。 ドキュメント名は5桁の数字+英数字 画像は5桁の数字+アルファベット1文字です。 例えばフォルダ名12345Ctest、ドキュメント名12345Ctest.indd、で試すとCに12345A.psdが配置されます。getFilesの中で一番若いものになるみたいです。回避方法教えてください。
var Doc=app.activeDocument, DocF = Folder(Doc.filePath), FN=Doc.name.replace(/^([0-9]+)(.+$)/,"$1"),//品番抜き出し FList = DocF.getFiles(/.*\.(jpe?g|tiff?|eps|psd)$/i), Ph= Doc.allPageItems; for(var i=0; i<Ph.length; i++){ if(Ph[i].constructor.name == 'TextFrame'&& /^[A-Z]$/.test(Ph[i].contents)){ var Nm=Ph[i].contents; for(var j=0; j<FList.length; j++){ if(RegExp(FN+Nm).test(FList[j])){ try{Ph[i].contents="";//try外すとcontents is undefinedエラー Ph[i].place(File(FList[j])); Ph[i].allGraphics[0].fit(FitOptions.FILL_PROPORTIONALLY); }catch (e){ } } } } }
|
No.10255 2022/05/02(Mon) 14:04:16
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15
|