A Script for Cleaning Up Empty Text Frames
This is a guest post from a longtime reader, Masood Ahmad.
In my work, I often receive InDesign files containing several empty text frames created unknowingly by another user. As most of you know, double-clicking a frame with the Type tool converts that frame into a text frame. This can lead to problems like missing font warnings when (nearly) empty text frames contain one or more non-printing characters like spaces.
To get rid of these unwanted text frames, I used to manually search and convert them into unassigned frames (Object > Content > Unassigned). But I also remembered reading about a script that could do the job faster and easier. So I searched and found an article here at InDesignSecrets about Finding Empty Text Frames. The article include the script DeleteEmptyFrame.jsx by Harbs at InTools.
This was great, but it did some things that I didn’t want, like deleting empty text frames with fill colors or strokes. In my documents, empty frames with fills or strokes were template items, so I didn’t want them to be deleted. Also, this script wouldn’t remove frames containing just spaces.
Digging deep into the problem, I found a thread on the Adobe InDesign user forum about a script to convert empty text frames to unassigned frames. And at the end of the forum, I found some more information about using Find/Change to remove spaces. So I tried editing the script (though I’m not a script writer) and it worked!
Since I know many of us face this kind of issue, I thought of sharing it with you all. This script, called EmptyTextFramesRemoverAndConverter.jsx, will delete all text frames in a document with no stroke, no fill, and no text wrap if they are completely empty or if they contain just white space. It will delete them even if they are hidden (using Object > Hide), anchored, or pasted into other frames. It will not delete frames on hidden or locked layers, or frames that are grouped with other objects. Frames that are retained are converted from text frames to unassigned frames.
Wondeful! Thanks Masood!
Ahem…
That script (with the exceptions of lines 5-8) was hosted on my page https://colecandoo.com/2013/12/22/a-christmas-treat-empty-frame-remover-v1-0/ .
The script actually removes frames with no text IF THEY:
* contain no images, AND
* have no fill, AND
* have no stroke, AND
* have no text wrap, AND
* are any closed shape, AND
* are not part of a group, AND
* are empty text, graphic or unassigned frames, AND
* have no type on a path around it
The script was an improvement of one developed by Siva Prasath but greatly improved upon with the help of Uwe Laubender.
As it says in line 4, “This script is a BETA only – use it only at your own risk!”
The lines that have been added to the original script are somewhat incorrect. The lines
app.findGrepPreferences.findWhat = /\A\s+\Z/.source;
/*app.changeGrepPreferences.changeTo = „”;
*/
This will find any white spaces only, and between the start and end of a story; but the /* */ tags need to be removed and the „”; removed and replaced with double straight quotations “”;
should be these lines:
app.findGrepPreferences.findWhat = /\A\s+\Z/.source;
app.changeGrepPreferences.changeTo = “”;
Otherwise it is a good addition to a script that truly has been the result of many collaborating interests.
Colin, you really have the eyes of an eagle. As I said in my article that I’m not a script writer. It’s true, I really do not know programing at all but I like to troubleshoot whenever I’m free. I just tried to mix up two different scripts into one and to my surprise, it worked :)
The script worked fine for me therefore, I shared it through the Forum. Now I can’t take the risk of editing it. However, I will keep your suggestion in my notebook and who know, I’ll again play with it.
Thank you very much for this script idea
This is good script, but I don’t want to delete empty frames from Master page, is it possible to modify the script for not deleting text frames from Master page?