Copy link to clipboard
Copied
Hi all
I have found this script and it works perfectly for its purposes (if an entire row has no data/length, then remove it).
var myDocument = app.activeDocument;
for(var i=myDocument.textFrames.length-1; i>=0; i--){
for(var j=myDocument.textFrames.tables.length-1; j>=0; j--){
for(var k=myDocument.textFrames.tables
myContents = 0;
for(var l=myDocument.textFrames.tables
if (myDocument.textFrames.tables
}
if (myContents == 0) myDocument.textFrames.tables
}
}
}
However, in the first column of my table, I have some text, and in the second column, I have no data.
How do I delete an entire row (including the first column containing text) using a script if just one cell of the row is blank?
I like the above script as I don't have to enter a table to run it - i.e. it will just apply to the whole document as I have many pages...
Thanks!
Hi,
I would think, that this can be done with one loop, instead of three:
var doc = app.activeDocument,
_cells = doc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();
for ( var k = _cells.length-1; k>= 0; k-- ) {
if ( _cells
.contents == "" ) _cells .rows[0].remove(); }
– Kai
Copy link to clipboard
Copied
You will find solutions, if you follow my link in my answer above.
EDIT: Oops. You mentioned 8,000 documents…
Uwe
Copy link to clipboard
Copied
Peter Kahrel has a script that can batch process InDesign files.
And you can run a script along with this batch run.
Uwe
Copy link to clipboard
Copied
Thanks Uwe – I'll have a look at that.
Copy link to clipboard
Copied
Thanks again Jared and Uwe for all your help. I have ended up with the below script that removes tags, removes hidden characters and then deletes rows from a table which have an empty data cell. I am looking in to batch processing now.
app.documents.everyItem().xmlElements.item(0).xmlElements.everyItem().untag();
var aDoc = app.documents[0];
var allTables = aDoc.stories.everyItem().tables.everyItem().getElements();
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "<FEFF>";
app.changeTextPreferences.changeTo = "";
aDoc.stories.everyItem().tables.everyItem().changeText();
app.findTextPreferences = app.changeTextPreferences = null;
alert("done");
var
doc = app.activeDocument,
_colls = doc.stories.everyItem().tables.everyItem().columns[-1].getElements(), cCol,
_cells, cCell, k,
checkWhiteRegEx = new RegExp ("\\S");
while (cCol = _colls.pop() ) {
_cells = cCol.cells.everyItem().getElements();
while (cCell = _cells.pop()) {
if ( !checkWhiteRegEx.test(cCell.contents) )
cCell.parentRow.remove();
}
}
Copy link to clipboard
Copied
Hi Libby,
there is a lengthy discussion about special characters left over by datamerge.
See the details here:
Re: Multiple record data merge into paragraph styles-applies the wrong style
Do a TEXT search/replace to get rid of the special characters.
Search for (without the quotes): "<FEFF>"
Steps 2 and 3 might apply in your case.
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now