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  Obi-wan Kenobi 2 months ago.

  • Author
    Posts
  • #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?

    Thanks
    Dmitri

  • #98045

    Graham Park
    Member

    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
    (?=implant)i

    • #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
    Member

    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.

    (?=implant[\s|s|]\.|\,)i

  • #98071

    Graham Park
    Member

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

    (?=implant[\s|\[|\\|s|\:\.\,])i

    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:
      (?=implant[\s|\[|\\|s|\:\.\,|\{])i

      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 “|’|\(|\)

      (?=implant[\s|\[“|’\(|\)|\\|s|\:\.\,|\{])i

    • #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
    Member

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

    (?=implant(s|[[:punct:]]))i

  • #98112

    Graham Park
    Member

    Sorry missed the space

    (?=implant(s|\s|[[:punct:]]))i

  • #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:

    (?=implant(s*)\b)i

    Hope this helps!!

  • #98116

    Graham Park
    Member

    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
    Member

    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

    Hi

    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=https://flic.kr/p/YxAZow][img]https://farm5.staticflickr.com/4336/37113617246_34fcf656bc_c.jpg[/img][/url][url=https://flic.kr/p/YxAZow]Screen Shot 2017-09-18 at 16.02.22[/url] by [url=https://www.flickr.com/photos/dimelot/]Dimitri de Bruyn[/url], on Flickr

  • #98168

    Graham Park
    Member

    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

    Hi,

    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.