• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

delete all text frames with the word "abc"

Explorer ,
Nov 14, 2017 Nov 14, 2017

Copy link to clipboard

Copied

Hello!

I'm trying to find a way to delete all text frames witch has the word "abc".

I found this script from https://forums.adobe.com/thread/690303 but it doesn't delete all the text frames with the "word" I want.

Does anyone can help me?

Thank you!

app.findGrepPreferences = NothingEnum.nothing;

app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.findWhat = "my+.+grep"; // << Edit your GREP here

with(app.activeDocument) {

     for(Counter = 0; Counter < textFrames.length; Counter++) {

           var MyResult = textFrames.item(Counter).findGrep();

                    if (MyResult.length == 0) {

                  textFrames.item(Counter).remove();

           }

     }

}

TOPICS
Scripting

Views

700

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Nov 14, 2017 Nov 14, 2017

var main = function(){

var doc = app.properties.activeDocument;

if ( !doc ) return;

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "abc"; // << Edit your GREP here 

var found = doc.findGrep();

var n = found.length, text, tf;

while ( n-- ) {

text = found;

if ( !text.isValid ) continue;

if ( !text.parentTextFrames.length ) continue;

text.parentTextFrames[0].remove();

}

}

var u;

app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "ABC" );

Votes

Translate

Translate
People's Champ ,
Nov 14, 2017 Nov 14, 2017

Copy link to clipboard

Copied

var main = function(){

var doc = app.properties.activeDocument;

if ( !doc ) return;

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "abc"; // << Edit your GREP here 

var found = doc.findGrep();

var n = found.length, text, tf;

while ( n-- ) {

text = found;

if ( !text.isValid ) continue;

if ( !text.parentTextFrames.length ) continue;

text.parentTextFrames[0].remove();

}

}

var u;

app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "ABC" );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2017 Nov 16, 2017

Copy link to clipboard

Copied

Hi Loic,

your script works for not threaded text frames.


If we consider stories that flow through more than one text frame, we have to be very cautious.
For this case I would first remove the text of the frame and then the frame itself.

Hm… And there could be more than one parent text frame for one single instance of found text.

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 14, 2017 Nov 14, 2017

Copy link to clipboard

Copied

It works perfectly!!

Thank you very much Logic.Aigon!!

Kind regards!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 16, 2017 Nov 16, 2017

Copy link to clipboard

Copied

LATEST

Hi Uwe,

You are right and thanks for pointing this. I think now our friend has everything to build his own bulletproof script

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines