Last active
September 21, 2025 16:59
-
-
Save AJABON/f9135eb456f1c7df6eedb611a4e1211f to your computer and use it in GitHub Desktop.
InDesign アクティブなページ/スプレッド上すべて正規表現検索置換
This file contains hidden or 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
| // id_changeGrepOnPageOrSpread.jsx (z-) | |
| // InDesignのアクティブなページ / スプレッド上のテキストフレームだけを正規表現検索置換する | |
| // 正規表現検索置換は、アプリ標準の検索置換ウィンドウ上で設定しておいてください。 | |
| // テキスト検索置換には非対応です | |
| // | |
| // 2025.09.16 ver_a てきとう | |
| // 2025.09.17 ver_b 検索文字、検索形式がととのっているか最初にチェックするよう改善 | |
| try{ | |
| app.findGrep(); | |
| }catch(e){ | |
| alert("正規表現検索のエラー\n検索文字列、検索形式を設定しといてください"); | |
| exit(); | |
| } | |
| var pr = prompt("対象は?\n1: ページ\n2: スプレッド", "1"); | |
| if(pr != "1" && pr != "2") exit(); | |
| var tgt = pr == "1" ? app.activeWindow.activePage : app.activeWindow.activeSpread; | |
| var ary = []; | |
| for(var i = 0; i < tgt.allPageItems.length; i++) { | |
| if(tgt.allPageItems[i].reflect.name === "TextFrame") { | |
| ary.push(tgt.allPageItems[i]); | |
| } | |
| } | |
| app.doScript(changeGrepAll, ScriptLanguage.JAVASCRIPT, [], UndoModes.FAST_ENTIRE_SCRIPT); | |
| function changeGrepAll(){ | |
| for(var i = 0; i < ary.length; i++){ | |
| ary[i].changeGrep(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment