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

Delete a Conditional tag in a Book - Script

New Here ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

Hi,

 

I want to delete certain conditional tags for all files in a Book without having to delete the tags file by file.

However, I couldn't find an easy batch function in FM interface.

With references from other scripts, I wrote this script to delete specified conditional tags in a Book.

The script is only available to delete an unused Cond tag you specified, not considering the cases that the tag is used in expressions or applied to the text. (Violent lol)

However,  I am not sure if  this would ruin the conditional tag structure in FM.

Does anyone have experience on this?

It will be great if someone would help check this script and share your experiences on this.

(or you have other tips on deleting cond tags?)

Many thanks.

----------------------------------------------------------------------------------------------

var book = app.ActiveBook;
var Condname=prompt("Please enter the condition tag you want to delete");//user input cond name
if (Condname!=null){
alert(Condname);

var comp = book.FirstComponentInBook;


/*go through files*/
while(comp && comp.ObjectValid() ){
alert (comp.Name);
var openedBook = OpenFile(comp.Name, false);
if(openedBook.ObjectValid())
DeleCond(openedBook, Condname);//call the DeleCond function
comp = comp.NextBookComponentInDFSOrder;
}

 

function DeleCond(doc, Condname){
doc.ShowAll = 1;//show all
var condFmt = doc.GetNamedCondFmt (Condname);
if (condFmt.ObjectValid () == 1) 
     condFmt.Delete ();
}

Views

144

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 ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

Rick Quatro's FindChangeFormatsBatch plugin does this, in bulk even.  http://www.frameexpert.com/store/#:~:text=for%20only%20%24169!-,FindChangeFormatsBatch,-FindChangeFo...

 

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 ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

Echoing Lin's reply...

Purchasing Rick's FindChangeFormatsBatch at frameexpert.com will be a fraction of the effort (and cost, in terms of hours) that you'll spend developing your own script to do this.

Additionally, you'll get access to changing/removing a half dozen other styles/template components.

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
New Here ,
Aug 20, 2022 Aug 20, 2022

Copy link to clipboard

Copied

LATEST

I was just getting into FM scripting and trying to write my first FM script though:) I did know Rick has lots of powerful scripts. You're right, FindChangeBatch should really save the scripting time and also support other powerful functions. I would  check that out. Thanks for the suggestion!

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
New Here ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

Hi,

 

I want to delete certain conditional tags for all files in a Book without having to delete the tags file by file.

However, I couldn't find an easy batch function in FM interface.

With references from other scripts, I wrote this script to delete specified conditional tags in a Book.

The script is only available to delete an unused Cond tag you specified, not considering the cases that the tag is used in expressions or applied to the text. (Violent lol)

However,  I am not sure if  this would ruin the conditional tag structure in FM.

Does anyone have experience on this?

It will be great if anyone would help check this script and share your experiences on this.

(or you have other tips on deleting cond tags?)

Many thanks.

----------------------------------------------------------------------------------------------

var book = app.ActiveBook;
var Condname=prompt("Please enter the condition tag you want to delete");//user input cond name
if (Condname!=null){
alert(Condname);

var comp = book.FirstComponentInBook;


/*go through files*/
while(comp && comp.ObjectValid() ){
alert (comp.Name);
var openedBook = OpenFile(comp.Name, false);
if(openedBook.ObjectValid())
DeleCond(openedBook, Condname);//call the DeleCond function
comp = comp.NextBookComponentInDFSOrder;
}

 

function DeleCond(doc, Condname){
doc.ShowAll = 1;//show all
var condFmt = doc.GetNamedCondFmt (Condname);
if (condFmt.ObjectValid () == 1) 
     condFmt.Delete ();
}

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 ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

Merging into duplicate thread.

 

Do not post multiple threads on the same topic.

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 ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

A big caution here: Deleting a condition tag will delete any text that has this condition applied.

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