Delete a Conditional tag in a Book - Script
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 ();
}
