Community
    • Login

    rename files

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 38 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.
    • FranciscoF Offline
      Francisco
      last edited by

      Fellow Notepad++ Users,

      Could you please help me the the following search-and-replace problem I am having?

      DESCRIBE CIRCUMSTANCES OF YOUR QUESTION

      I would like to make these files available for download (or just for text viewing), but with the filenames changed—keeping only the part of the name that appears before the underscore.
      Here is the data I currently have (“before” data):

      “C:\contest\cvadx\2024\CW\DL8FMA_8U5QC.txt”
      “C:\contest\cvadx\2024\CW\DL8UKW_8WMM6.txt”
      “C:\contest\cvadx\2024\CW\DL8UKW_RMXE3.txt”
      “C:\contest\cvadx\2024\CW\DM1AA_6J2IN.txt”

      
      Here is how I would like that data to look ("after" data):
      

      “C:\contest\cvadx\2024\CW\DL8FMA.txt”
      “C:\contest\cvadx\2024\CW\DL8UKW.txt”
      “C:\contest\cvadx\2024\CW\DL8UKW.txt”
      “C:\contest\cvadx\2024\CW\DM1AA.txt”

      very thanks
      Francisco Freitas

      1 Reply Last reply Reply Quote 0
      • gerdb42G Offline
        gerdb42
        last edited by

        @francisco this is a classical task for a RegEx Search/Replace.

        Open Replace Dialog and select “Regular Expression” as Search Mode. At “Find what” enter ^(.*)_[^.]*. At “Replace with” enter $1. Hit “Replace All”.

        You may want to have a look at https://npp-user-manual.org/docs/searching/#regular-expressions for an introduction to Regular Expression Searches. For further reading have a look at https://community.notepad-plus-plus.org/topic/15765/faq-where-to-find-regular-expressions-regex-documentation. You will find a lot of useful information and links there.

        1 Reply Last reply Reply Quote 0
        • guy038G Online
          guy038
          last edited by

          Hello, @francisco, @gerdb42 and All,

          There are plenty of solutions !

          The following one will ensure that the . matches newline option will not be used even it’s checked and that the Match case option is enabled even it’s not checked !

          FIND (?-si)_.+(?=\.txt)

          REPLACE Leave EMPTY

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 0

          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