Community
    • Login

    How I can convert urls in a text file to clickable links??

    Scheduled Pinned Locked Moved General Discussion
    lineshtml
    4 Posts 3 Posters 8.9k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R kR Offline
      R k
      last edited by R k

      I have multiple text files having links in seperate lines.

      https://example.com/pic1.jpg
      https://example.com/pic2.jpg
      https://example.com/pic3.jpg
      .
      .
      .

      I want to make all links clickable and save it with .html extension.

      This is what i want to achieve and save as .html
      <a href=“https://example.com/pic1.jpg”>https://example.com/pic1.jpg</a>
      <a href=“https://example.com/pic2.jpg”>https://example.com/pic2.jpg</a>
      <a href=“https://example.com/pic3.jpg”>https://example.com/pic3.jpg</a>

      This website
      Helped me create above html tags
      https://www.textfixer.com/html/convert-url-to-html-link.php

      But can Notepad++ do this same on my multiple files?
      I have around 40-50 txt files with links.

      astrosofistaA 1 Reply Last reply Reply Quote 0
      • astrosofistaA Offline
        astrosofista @R k
        last edited by

        Hi @R-k

        I assume that the curly quotes in the example data you posted are actually straight quotes (*). If that is the case, then the following regex will convert any line that starts with http:// or https:// into a clickable link:

        Search: (?-s)^https?://.+$
        Replace: <a href="$0">$0</a>
        
        

        Put the caret at the very beginning of the document, select just the Regular Expressions mode and click the Replace All button.

        Take care and have fun!

        (*) Note: When you post data, please highlight the examples and then press the </> button above in order to prevent the website from mangling the data, as did happened in this case with double quotes.

        1 Reply Last reply Reply Quote 4
        • guy038G Offline
          guy038
          last edited by guy038

          Hello @r-k and All,

          Very easily !

          • Open the Find in Files dialog ( Ctrl + Shift + F )

            • SEARCH ^(?-si)http.+$

            • REPLACE <a href="$0">$0</a>

            • Type in *.txt in the Filters: zone

            • Type in the absolute path to your 40-50 text files in the Directory: zone

            • Select the Regular expression search mode

          • Click on the Replace in Files button and valid the confirmation dialog

          Et voilà !


          IMPORTANT : Before applying this S/R to your set of files, give it a try against ONE test file, only :

          • Open the Replace dialog ( Ctrl + H )

            • …

            • …

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

          Best Regards

          guy038

          P.S. : In fact, @astrosofista just beat me ;-))

          R kR 1 Reply Last reply Reply Quote 4
          • R kR Offline
            R k @guy038
            last edited by

            @guy038 OP here! This is exactly what I was looking for. Thank You.

            1 Reply Last reply Reply Quote 1

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors