mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-30 12:15:56 +00:00
* new skill adobe-illustrator-scripting * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
33 lines
893 B
JavaScript
33 lines
893 B
JavaScript
// find-replace-text.jsx
|
|
// Finds and replaces text across all text frames in the active document.
|
|
// Usage: Run from File > Scripts > Other Scripts in Adobe Illustrator.
|
|
|
|
#target illustrator
|
|
|
|
(function () {
|
|
if (app.documents.length === 0) {
|
|
alert("No document is open.");
|
|
return;
|
|
}
|
|
|
|
var doc = app.activeDocument;
|
|
|
|
var findStr = prompt("Find text:", "");
|
|
if (findStr === null || findStr === "") return;
|
|
|
|
var replaceStr = prompt("Replace with:", "");
|
|
if (replaceStr === null) return;
|
|
|
|
var count = 0;
|
|
for (var i = 0; i < doc.textFrames.length; i++) {
|
|
var tf = doc.textFrames[i];
|
|
var original = tf.contents;
|
|
if (original.indexOf(findStr) !== -1) {
|
|
tf.contents = original.split(findStr).join(replaceStr);
|
|
count++;
|
|
}
|
|
}
|
|
|
|
alert("Replaced text in " + count + " text frame(s).");
|
|
})();
|