is now part of CreativePro.com!

How to Make the File Extension Go Away in Captions

23 0

Kelly wrote:

Does anyone know how to remove the file extension when using static captions? I want to get to get rid of .jpg, but not sure how.

I love the topic of “make it go away!”

The problem is that when you define a caption in InDesign (Object > Captions > Caption Setup), there’s no way to say “drop the last part of the file name” in the Caption Setup dialog box:

caption setup

So when you select an image and choose Object > Caption > Generate Static Caption (or Generate Live Caption), you get the whole name! Here’s an example:

More after the jump! Continue reading below
Free and Premium members see fewer ads! Sign up and log-in today.

static caption

As long as you use a static caption (not live), you can edit the text any way you want. For example, you could just delete the .jpg at the end. But that would be tiresome if you had to do it a lot. Instead, if you want the file name, but not the dot-extension at the end, you could apply a GREP style to the paragraph style:

disappear grep style

What the heck is that disappear character style? Basically, I just made a character style defined as: color = none, size = .1 pt, and horizontal scale = 1%. Anything you apply that to will virtually (not entirely, but good enough) disappear. In this case, the style is being applied to backslash-period-period-plus-dollar, which means, “all text from the last period to the end of the paragraph.”

Waalahhh! (Clearly, French isn’t my first language.)

Unforunately, this will not work on live captions or text variables because those are literally treated as a single character — InDesign can’t “see inside” them to see the text or edit it.

However, if you have already created a lot of live captions, you will be happy to hear that there’s a script that can convert them to static captions for you. It’s called Convert Variables to Text. When you run the script, it instantly converts all variables—including captions— to live text. Download the script here.

(Okay, before someone else chimes in with this: Yes, I know you could also just use that grep code in the Find/Change dialog box to literally delete the text. But why delete if you don’t need to? Maybe tomorrow your client or art director will suddenly change their mind and want them there after all.)

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world. You can find more about David at 63p.com.
  • Michael says:

    The regular expression actually matches everything from the first period, not the last. To match from the last period you should use \.[^.]+$

  • Colmin8r says:

    another suggestion:
    before placing the pics, go into bridge and add titles to the pictures. there is a brilliant script (plus instructions) to do this at:
    https://forums.adobe.com/message/3899179#3899179
    this script adds a “document title” to the XMP info using the filename but removes the suffix.
    while testing this, noticed the live caption would not update a pic which had title data added after it had already been placed into indesign, so the bridge step has to be done first!

  • @Michael: Wow, that is a great point! Thank you. Another way do to it would be \.\w+$, which means a dot followed by one or more “word characters” (numbers or letters), followed by the end of the paragraph.

  • Jongware says:

    I don’t know. What happens if you come across a file that has no extension?
    Another possibility is to explicitly cull away only the ones you are sure to encounter:

    (?i)\\.(jpg|jpeg|png|gif|pdf|eps|ai|psd)$

    The (?i) switches on ‘Ignore Case’ so that won’t bother you.

  • Mike Rankin Mike Rankin says:

    In case anyone needs a translation of Michael’s nifty expression:

    It’s a period

    \.

    followed by anything NOT a period

    [^.]

    one or more times

    +

    followed by the end of paragraph

    $

  • John Tax says:

    Good work!

    (by the way, french is: Voilà !

    But i like the Whalaa much more (maybe cos’ i’m french)

    thanks again.

    J.

  • Love the Bridge script! I’m fiddling with it now. thanks!

    • Ben says:

      I understand I’m a year and a half late to the conversation. The Bridge script would solve some headaches for me!

      Bridge CS6 is complaining that it can’t execute this script (due to version issues, I think).

      Anne-Marie, is your version of the script functional in later versions of Bridge?
      Perhaps you fiddled it into compatibility? If so, could you please share your version?

  • Ben, I’m sorry, I haven’t looked at it in a while. I’ll add it to my to do list …

  • Peter says:

    I’m probably a couple of years too late, but what about creasting a style for your caption. Then apply the caption style to all your captions and running a ‘Find and Replace’ for “.jpg” or whatever extension you wish to remove using an added ‘Caption’ paragraph style as an added search criteria. This will restrict your search to only include ‘Caption’ styles. I only have to run it once.

  • Bart?omiej Stark says:

    Hello, is it possible to get this scripte – I can’t find it anywhere? Or mayby there is any script, which will edit metadata of picture – so I could click and write description or change name etc and after refresh I see caption(when I open “File info” or “XMP Info”, I can’t change metadata). Best regards.

  • Crystal says:

    I used static captions and then did a find & replace (CTR + F) to remove all of the file extensions. Worked Great :)

  • rafael says:

    Hello, I need to remove only the .psd name.
    I’m using in style options, grep style this code: \ .psd \ w + $
    You are not removing the extension, what am I doing wrong?

  • John Kramer says:

    Several years later…

    “Marijan Tompa has created a script that can convert them to static captions for you, called variable2Text Converter….”

    Link to this script (nor to his site in general) no longer works. Anyone happen to have this script or a link to it?

    Thanks!

    • Mike Rankin Mike Rankin says:

      Hi John- I just updated the article with a different script that does almost the same thing.

      • Natalie Dennett says:

        Hi Mike, I love this script, but is there a way to run it so it only converts the captions on the layout pages to static and not the master page captions as well? I’d like to keep the master page captions live.

      • Mike Rankin Mike Rankin says:

        Sorry, Natalie. I think someone would have to write a different script that let you exclude captions on master pages. I tried locking, hiding, even exporting captions on masters to InCopy as a workaround but this script is a very blunt instrument, it converts every caption in the document or gives an error if it can’t.

  • Cassie Dalton says:

    Hi everyone, I’m just wondering if there have been any advancements in this recently.
    I do a magazine every month that has 100s of PDFs imported into indd. I need to add the file name underneath without the .pdf extension. It needs to be variable as the PDFs change every month.
    Just wondering if anyone has any ideas.
    Thanks

    • David Blatner David Blatner says:

      Nope… nothing has changed. You can use the GREP Style or just a GREP find/change. (Or even a regular text find/change… just search for .PDF and delete it.) :-)

  • >