Copy link to clipboard
Copied
Hello everyone!
I ran into an interesting problem. I need to select the third and fourth letters in 2400 words (these are number combinations, for example 0101A / 0102A... etc.) and change their style (make them bigger and more prominent). Is there any way to do this in bulk using a script in Indesign? I'm sure there is but I can't find a source to refer to, like the Find/Replace function. At the moment I do it by splitting the words into 3 columns in Excel and inserting them into Indesign by merging data. It's a good pretty quick option but I think indesign can play with it much more elegantly. Anyone have any ideas? I would be very grateful for everyone's help!
There is example of what I need:
original:
what I need:
Thanks!
Sending greetings from Czech Rep.
Martina
If each word is in its own text frame, this should do the job:
var st = app.activeDocument.stories;
for(i=0; i<st.length; i++) {
if(st[i].characters.length >= 3 ) {
st[i].characters[2].fontStyle = st[i].characters[3].fontStyle = "Bold";
st[i].characters[2].pointSize = st[i].characters[3].pointSize = 14;
}
}
Before:
After:
Would a nested style work?
This works like the examples given, so long as each affected word is in its own paragraph…
This works if there are multiple words in a paragraph (but only if you want every word affected)…
If you need the format applied selectively within text then you might need to use GREP, which matches specific and complex patterns (e.g. only five letter words that start with numbers and contain letters).
Copy link to clipboard
Copied
If each word is in its own text frame, this should do the job:
var st = app.activeDocument.stories;
for(i=0; i<st.length; i++) {
if(st[i].characters.length >= 3 ) {
st[i].characters[2].fontStyle = st[i].characters[3].fontStyle = "Bold";
st[i].characters[2].pointSize = st[i].characters[3].pointSize = 14;
}
}
Before:
After:
Copy link to clipboard
Copied
@GNDGN THANK YOU SO MUCH!!
This is game changer 😄 😄 I knew there will be a way.
This briliatnt. Working perfectly for me!
Copy link to clipboard
Copied
Would a nested style work?
This works like the examples given, so long as each affected word is in its own paragraph…
This works if there are multiple words in a paragraph (but only if you want every word affected)…
If you need the format applied selectively within text then you might need to use GREP, which matches specific and complex patterns (e.g. only five letter words that start with numbers and contain letters).
Copy link to clipboard
Copied
Wow, this also looks great - I will tested! Thank you so much. @Scott Falkner
Copy link to clipboard
Copied
So this also work perfectly for me!
Copy link to clipboard
Copied
second and third letters or numbers of every word
GREP Style:
\b(\w\w)\K\w\w
All roads lead to Rome
Copy link to clipboard
Copied
Hello @Martina zstudio
and the other grep:
.{2}(?=.\t|.$)
For use in GREP Style in paragraph style* ou in Find/Change.
* This is the best way because the text is automatically formatted wherever the paragraph style is applied. However this will always be an indirect formation, for PDF and the like it will be kept. For copying and pasting between applications, it may not work at the destination.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now