Skip to main content
Participant
April 11, 2020
Question

InDesign Live Captions GREP styles (remove prefix & suffix from name)

  • April 11, 2020
  • 3 replies
  • 3594 views

Hello, I found the post about removing the file extension at the end of a live caption, but I am also trying to remove a number followed by a period at the beginning. My client shares photo files with this naming style: "1. Caption of image is written out here.jpg". The numbering goes from single to double digits, and is always followed by a period and a space. I am trying to automatically remove the number, period, and space at the beginning as well as the file extension at the end, while keeping the middle bit as my live caption. Any suggestions?

 

Thanks!

3 replies

Peter Villevoye
Community Expert
Community Expert
April 26, 2020

Nice, all these tips ! That should get the ball rolling' 🙂

FRIdNGE
April 26, 2020

Hi!

 

Surely the kind of answer [David's one] I would have given years ago, but not now anymore! …

 

Go to Bridge, open the images folder and updating, e.g., the "Title" metadata with this kind of Grep treatment:

 

"Title" (metadata) = Filename.replace(/^\d+\.\s/, "").replace(/\.\w+$/, "") (metadata)

 

See the screenshot: filename = "2. Photo_ZZZ.JPG" ==> title = Photo_ZZZ

 

 

[1 click!]


Come back to InDesign, select all the links in the Links panel and update them! [idem]

 

That's all: All the captions are still "live", no "static" at all!

 

(^/) The Jedi

David Popham
Participating Frequently
April 27, 2020

Hi Michel,

 

That's a cool trick. However, I could not get it to work. I'm getting the literal text from the Title field. I tried some variations of the code string in the event that I'm misinterpreting what should go in the field, but no luck.

David Popham
Participating Frequently
April 26, 2020

As Peter indicated, you can't delete characters with a GREP style; however, you can hide them if that's a solution that works for your project.

 

1. Create a character style with a Size of 0.1 and the Character Color set to None.

 

2. In your caption paragraph style, in the GREP Style pane, create two GREP styles applying the character style using the following GREP patterns:

^\d{1,2}\.\s

\.jpg$

David Popham
Participating Frequently
April 26, 2020

Guess I should test before posting, as the solution above will only work if the Live Caption is converted to a Static Caption. InDesign sees the text in Live Captions as a single entity, not as individual characters.

Peter Villevoye
Community Expert
Community Expert
April 26, 2020

I'm not a from-the-top-of-my-head GREP formulist, so you have to do some tinkering yourself.

Because I did find many articles discussing some GREP sequences in a comprehensible manner.

Simply Google "indesign grep delete characters" and they tumble over your screen, like this one:

https://indesignsecrets.com/indesign-grep-essentials-how-to-add-delete-and-re-arrange-text.php

Note: you can't assign a GREP Style to edit a text, but you can let GREP do it in Find/Change.