javascriptadobe-indesigngrep-indesign

Adobe InDesign Find/Change script


in order to make my work with InDesign easier, I've generated this Find/Change script using chainGREP. This is part of code only:

// Query [[Query GREP1]] -- If you delete this comment you break the update function
        try {
            app.findChangeGrepOptions.properties = ({includeHiddenLayers:true, includeMasterPages:true, includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
            app.findGrepPreferences.properties = ({justification:1667591796, appliedFont:"Open Sans", fontStyle:"Bold", pointSize:10});
            app.changeGrepPreferences.properties = ({paragraphDirection:1379028068, characterDirection:1147496036, digitsType:1684627826, kashidas:1801544805, justification:1667591796, composer:"Adobe World-Ready Paragraph Composer", appliedFont:"Adobe Arabic", fontStyle:"Bold", pointSize:15, leading:15, appliedLanguage:"Arabic"});
            changeObject.changeGrep();
        } catch (e) {alert(e + ' at line ' + e.line)}
        app.findGrepPreferences = NothingEnum.NOTHING;
        app.changeGrepPreferences = NothingEnum.NOTHING;
        // Query [[Query GREP2]] -- If you delete this comment you break the update function
        try {
            app.findChangeGrepOptions.properties = ({includeHiddenLayers:true, includeMasterPages:true, includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
            app.findGrepPreferences.properties = ({justification:1667591796, appliedFont:"Open Sans", pointSize:8});
            app.changeGrepPreferences.properties = ({paragraphDirection:1379028068, digitsType:1684627826, justification:1667591796, composer:"Adobe World-Ready Paragraph Composer", appliedFont:"Adobe Arabic", pointSize:11, leading:11, appliedLanguage:"Arabic"});
            changeObject.changeGrep();
        } catch (e) {alert(e + ' at line ' + e.line)}
        app.findGrepPreferences = NothingEnum.NOTHING;
        app.changeGrepPreferences = NothingEnum.NOTHING;
        // Query [[Query GREP3]] -- If you delete this comment you break the update function
        try {
            app.findChangeGrepOptions.properties = ({includeHiddenLayers:true, includeMasterPages:true, includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
            app.findGrepPreferences.properties = ({justification:1667591796, appliedFont:"Open Sans", pointSize:11});
            app.changeGrepPreferences.properties = ({paragraphDirection:1379028068, characterDirection:1147496036, digitsType:1684627826, kashidas:1801544805, justification:1667591796, composer:"Adobe World-Ready Paragraph Composer", appliedFont:"Adobe Arabic", pointSize:15, leading:15, appliedLanguage:"Arabic"});
            changeObject.changeGrep();
        } catch (e) {alert(e + ' at line ' + e.line)}

Got only one question. Is it possible to put pointSize in range, eg.

pointSize>=10 && pointSize<=10.5

Or maybe there is easier way to automate Find/Change?


Solution

  • After getting the result from find/change, you may use javascript to do the pointSize checking.

    app.findGrepPreferences.findWhat = '.+';
    app.changeGrepPreferences.changeTo = 'changed';
    
    var results = app.findGrep();
    
    for (var i=0; i<results.length; i++){
        if (results[i].pointSize>=10 && results[i].pointSize<=10.5){
            results[i].changeGrep();
            }
        }