Use document name without extension and a grep question

Home Forums General InDesign Topics Use document name without extension and a grep question

This topic contains 17 replies, has 4 voices, and was last updated by  Michel Allio from FRIdNGE 9 months, 1 week ago.

  • Author
  • #98044

    Hi everybody

    First question:
    I want to use my document name as leading for a revision number on the back.

    for example:
    DEM0010-REV C_example document.INDD

    and I want to have DEM0010-REV C at the end of my document printed on the last page as a reference.
    I used ‘Variable text’ and a nested style. But nested styles don’t work with variable text.

    Is there another way to do this?

    2nd question:
    In the same document I need to write the word ‘implant’ or ‘implants’ with a capital.
    When I used Search and replace it is no problem, but it changes the word ‘implantation’ ass well.
    So I think i need to use grep for this, but I cannot find the right expression.

    Can someone help me please?


  • #98045

    Graham Park

    Set up as a GREP in the Paragraph Style, this way as you type the formatting will be added,no chance of missing any of them.

    Make a Character Stye for case ALL CAPITAL

    Set the GREP
    Apply Style CAPS

    • #98059

      @graham-park thanks it works great, but it also works on implantation and justimplant.Even though justimplant is not a real word. Do I have to make an exception grep style?

  • #98066

    Graham Park

    Sorry I stuffed that up.

    This one will work better and will get most instances.
    If you have punctuation other than comma or fullstop this will not work.
    Other punctuation would have to be added after a BAR separator.


  • #98071

    Graham Park

    This adds some more punctuation options to the GREP
    This GREP is a Positive Lookahead


    For punctuation add each with a BAR separator and a leading \ otherwise they will not been seen as a character
    For additional punctuation add them as follows

    eg |\{

    • #98110

      Thanks @graham-park

      final code:

      This code will cover the most. And it will do the job just fine.
      But I want to be sure to cover all possibilities. And if there is one possibility that could happen it is (implant) or ‘implant’ between

      So i added “|’|\(|\)


    • #98113

      That’s a very nice code :thumbs:

    • #98117

      Yesss.. that’s the one I had in mind. Thanks @kimmi-patterson

      So problem 2 is solved..

      Now I need a solution for problem 1 :)

  • #98111

    Graham Park

    That code is a bit inelegant.
    This is better use POSIX to shorten it and it will pick up all punctuation without a list.


  • #98112

    Graham Park

    Sorry missed the space


  • #98114

    You could also use Word Boundary in Locations, which will only find instances where implant(s) is the whole word. Then it wouldn’t matter what precedes or follows:


    Hope this helps!!

  • #98116

    Graham Park

    That is a nice solution.

    As to Dmitri first question about the revision name on the back of the using ‘variable text’.
    InDesign treats these type of items as a single character so no GREP, editing, formatting to part of the result are possible.

    I don’t think it is possible to do anything unless you convert the ‘variable text’ to text.

  • #98118

    Agreed on editing variable text. However, there may be a sneaky way to style with GREP or nested styles using the location of the variable text.

    For example, if the file name variable is the first character of the paragraph, a nested style could be applied to the first word, which would be the file name variable.

    Let us know how the variable will be used and we may be able to help :)

  • #98119

    Graham Park

    Yes a nested style can be applied to the whole variable text but not to part of it.

    InDesign treats these type of items as a single character so no GREP, editing, formatting to part of the result are possible.

    Dimitri can you post exactly what the variable text is and then how you want it to appear?
    It looked to me as though you wanted to remove part of the file name when it is placed. Or do you just want to format the result?

  • #98165


    It was a long weekend.. sorry for the delay..

    Anyway.. my document name is DEM0010-REV C_example document.INDD
    and I want to print DEM0010-REV C at the end of the brochure.

    I tried it with nested styles, after the underscore the color of the font would be none.
    But it doesn’t work with variable text, unless I convert it to normal text.

    I use the variable Documentname

    [url=][img][/img][/url][url=]Screen Shot 2017-09-18 at 16.02.22[/url] by [url=]Dimitri de Bruyn[/url], on Flickr

  • #98168

    Graham Park

    InDesign treats the text variables as a single character so you can only apply formatting to the whole string.
    As InDesign treats variable text as one character you can get some strange effects if the text box is too small, try it make the text box very short and see how the characters sit on top of each other, the text will not wrap to more than one line etc.

    The only way around this is, as you say, to convert it to text, then you can format it the same as any other text.

    • #98169

      Does this image work?

      Screen Shot 2017-09-18 at 16.02.22

      @graham-park I knew this, but I hoped for an solution.. Too bad.
      If I convert it to text and the revision changes it does not change in the document..

  • #98172


    Take a look to this video!

    The captions use metadata played as variables!
    The op needed to create a list [TOC] of the captions!
    The result was a “nice mess” [ID bug]!

    So, I’ve taken the bug and sit on it! …

    The captions are always “dynamic” [variable links]!

    In your case, you just need a small script! … [Not for free!]

    (^/) ;-)

You must be logged in to reply to this topic.