Hi jays; Find grep: ^~a\h*(.)
Change format:autobulletPstyle (paragraph style)
I would do it a bit more granular looping the allGraphics array of your document.
var allGraphicsInDoc = app.activeDocument.allGraphics;
Loop all entries in this array and check if the parent of the parent of an entry is a character.
That would be the most important check. If not you could loop on with a simple continue .
If it is a character, you found the anchor character and that gives you access to the paragraph where the graphic is anchored.
Also do some other checks while looping:
The next I would suggest: Is the graphic positioned at the very beginning of the paragraph? You basically ask:
Is the index value of the anchor character the same as the index value of the first character in the paragraph of the anchor character?
Perhaps also check, if itemLink of the graphic is undefined. We need itemLink to identify an EPS as EPS leaving e.g. a JPEG alone.
If itemLink is undefined loop on with continue, because we are not interested in pasted pixels. We are interested in graphics that have links, embedded or not ( my assumption ). Ask for itemLink.linkType that could return a string like "EPS".
Is the applied paragraph style of the anchor character the expected one?
You could ask this, if you want to remove anchored graphics only, if a certain paragraph style is applied to the text.
A trick is:
Select one of the graphics and store all sigificant values of the selection to variables.
What is significant? You decide, you know the document.
While looping you can ask, if the values of the selected graphic are identical with the one of the graphic you currently loop.
If not continue the loop without doing anything with statement continue.
Make sure that all graphics you want to remove really share the same significant values.
Same name? Do a check of itemLink.name . Otherwise don't use that check.
Hope, that gets you started.
I've seen that solution (putting $1 in the change field) elsewhere but whenever I try that, it replaces whatever I'm finding ("^\d\." -- without the quotes -- for example) with "$1". Otherwise, this solution would be perfect. I just can't get it to work like you and everyone else say it should.
Eventually, I found a script similar to what I needed that used itemLink.name -- one of the missing pieces I needed -- and that helped me to write one of two scripts I ended up using that I'll post later when I'm at home.