[GastForen Programme Print/Bildbearbeitung Adobe InDesign Skriptwerkstatt Automatisches ausfüllen von "xxxxx" GREP /Skript

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste
Print/Bildbearbeitung - Photos, Layout, Design
Themen
Beiträge
Moderatoren
Letzter Beitrag

Automatisches ausfüllen von "xxxxx" GREP /Skript

Arielle93
Beiträge gesamt: 13

8. Dez 2020, 15:47
Beitrag # 1 von 1
Bewertung:
(12408 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Halli Hallo,

ich nochmal... jetzt hab ich eine etwas schwierigere Aufgabe ...

Ich habe ein Dokument, eine Titelseite für ein Buch wo mehrere Sprachen aufgelistet sind. In verschiedenen Ebenen sind die Sprachen unterschiedlich angeordnet, aber teilweise ge"xxxxx"t, obwohl die Begriffe in anderen Ebenen bereits drin stehen.

Ich bräuchte also ein Skript (evtl mit Grep verbunden?) der mir die Gerätebezeichnung kopiert und dann diese Kopie in die xxxxx´e einfügt, bzw ersetzt.

Dieses Skript sucht mir den Begriff, löscht mir diesen aber leider, ich will diesen aber nur kopieren, ggf gibt es auch eine bessere lösung als "[A-W|Y-Z]" - er soll mir im Prinzip alles suchen außer "xxxxx" die Begriffe sind teilweise aber 1-5 Wörter lang:



Code
main(); 

function main() {
if (app.layoutWindows.length == 0) return;
var changeObject = app.documents[0];
if (changeObject.hasOwnProperty('characters') && changeObject.characters.length == 0) return;
var doc = app.documents[0];
var style;
var scriptVersion = app.scriptPreferences.version;
app.scriptPreferences.version = 16.0;
var options = app.findChangeGrepOptions.properties;
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
// Query [[a]] -- If you delete this comment you break the update function
try {
app.findChangeGrepOptions.properties = ({includeHiddenLayers:true, includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
app.findGrepPreferences.properties = ({findWhat:"(?<=D\\tSicherheitshinweise\\n)[A-W|Y-Z].+"});
app.changeGrepPreferences.properties = ({});
changeObject.changeGrep();
} catch (e) {alert(e + ' at line ' + e.line)}
app.findChangeGrepOptions.properties = options;
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.scriptPreferences.version = scriptVersion;
};

function getStyleByString(docOrGroup, string, property) {
if (string == '[No character style]') return docOrGroup[property][0];
if (string == '[No paragraph style]') return docOrGroup[property][0];
if (string == 'NormalParagraphStyle') return docOrGroup[property][1];
stringResult = string.match (/^(.*?[^\\]):(.*)$/);
var styleName = (stringResult) ? stringResult[1] : string;
styleName = styleName.replace (/\\:/g, ':');
remainingString = (stringResult) ? stringResult[2] : '';
var newProperty = (stringResult) ? property.replace(/s$/, '') + 'Groups' : property;
var styleOrGroup = docOrGroup[newProperty].itemByName(styleName);
if (remainingString.length > 0 && styleOrGroup.isValid) styleOrGroup = getStyleByString (styleOrGroup, remainingString, property);
return styleOrGroup;
};




Und dieses Skript sucht mir dann die xxx´e und ersetzt diese mit der Zwischenablage:




Code
main(); 

function main() {
if (app.layoutWindows.length == 0) return;
var changeObject = app.documents[0];
if (changeObject.hasOwnProperty('characters') && changeObject.characters.length == 0) return;
var doc = app.documents[0];
var style;
var scriptVersion = app.scriptPreferences.version;
app.scriptPreferences.version = 16.0;
var options = app.findChangeGrepOptions.properties;
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
// Query [[b]] -- If you delete this comment you break the update function
try {
app.findChangeGrepOptions.properties = ({includeHiddenLayers:true, includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
app.findGrepPreferences.properties = ({findWhat:"(?<=D\\tSicherheitshinweise\\n)(xxxxx)"});
app.changeGrepPreferences.properties = ({changeTo:"~c"});
changeObject.changeGrep();
} catch (e) {alert(e + ' at line ' + e.line)}
app.findChangeGrepOptions.properties = options;
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.scriptPreferences.version = scriptVersion;
};

function getStyleByString(docOrGroup, string, property) {
if (string == '[No character style]') return docOrGroup[property][0];
if (string == '[No paragraph style]') return docOrGroup[property][0];
if (string == 'NormalParagraphStyle') return docOrGroup[property][1];
stringResult = string.match (/^(.*?[^\\]):(.*)$/);
var styleName = (stringResult) ? stringResult[1] : string;
styleName = styleName.replace (/\\:/g, ':');
remainingString = (stringResult) ? stringResult[2] : '';
var newProperty = (stringResult) ? property.replace(/s$/, '') + 'Groups' : property;
var styleOrGroup = docOrGroup[newProperty].itemByName(styleName);
if (remainingString.length > 0 && styleOrGroup.isValid) styleOrGroup = getStyleByString (styleOrGroup, remainingString, property);
return styleOrGroup;
};




Zu bemerken ist noch, das die Grün hinterlegten Wörter variabel sind, da in Englischen die Sicherheitshinweise bei uns dann zb "GB\\tSafety instructions\\n" heißen... usw.
Ich müsste dieses Skript also selbst noch erweitern für Rund 25 Sprachen... und die Zwischenablage würde sich somit auch innerhalb des Skriptes immer ändern...
X