How to add asterisk to a list of filenames and make it a line



  • Hello.

    I’ve a list of file names (about 4000).

    For example:
    A-67569
    H-67985
    J-87657
    K-85897
    .
    .
    .

    I need to put asterisk before and after each file name. And make it a line format.

    Example:

    A-67569 H-67985 J-87657 K-85897

    Note that there is a space between filenames.

    How can I do it?

    Please advise.

    Thanks



  • After I posted, I noticed it’s not allowing to show the asterisks I put before and after the filenames. So please look at the pic in the link.

    link text

    Thanks



  • Hello @sunil-kumar and All,

    Not difficult with regular expressions ! So :

    • Open the Replace dialog ( Ctrl + H )

    SEARCH (?-s)(.+)\R

    REPLACE *\1*\x20

    • Select the Regular expression search mode

    • Move your cursor to the beginning of your list of files

    • Click several times on the Replace button or once, only, on the Replace All button

    Voilà !

    Notes :

    • As usual, the (?-s) modifier means that the regex dot character ( . ) represents a single standard character

    • Then, the part (.+) stands for any non-empty range of consecutive standard characters, which is stored as group1, as embedded in parentheses

    • The last part, \R matches any kind of line-break ( \r\n, \n or \r )

    • In replacement, we rewrite an asterisk, followed by the filename ( group1 ), followed, again, with an asterisk and, finally, with a space character ( \x20 )

    Best Regards,

    guy038

    P.S. :

    A small drawback is that the last file, of the unique line, is, of course, followed with a space char, too !


Log in to reply