Community
    • Login

    Create REN Batch File?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    renamebatch filefilenames
    4 Posts 3 Posters 1.6k 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.
    • Ron BallR Offline
      Ron Ball
      last edited by

      How can I automatically convert a list of filenames (in a text file) to reverse the filename based on a dash?

      My file has (hundreds) of filenames listed … (I can easily remove the .epub extension before conversion, and add it back after the list is “fixed”.)

      This would be the starting file contents …

      Pride and Prejudice - Jane Austen
      Moby Dick - Herman Melville
      A Tale of Two Cities - Charles Dickens
      

      This would be the converted file contents …

      REN "Pride and Prejudice - Jane Austen" "Jane Austen - Pride and Prejudice"
      REN "Moby Dick - Herman Melville" "Herman Melville - Moby Dick"
      REN "A Tale of Two Cities - Charles Dickens" "Charles Dickens - A Tale of Two Cities"
      
      EkopalypseE 1 Reply Last reply Reply Quote 0
      • EkopalypseE Offline
        Ekopalypse @Ron Ball
        last edited by

        @Ron-Ball said in Create REN Batch File?:

        Pride and Prejudice - Jane Austen
        Moby Dick - Herman Melville
        A Tale of Two Cities - Charles Dickens

        From the given example you would build three groups like
        find:(.+)( - )(.+)
        and
        replace: REN "$1$2$3" "$3$2$1"

        Hopefully your data is exactly as posted.

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

          Hello, @ron-ball and All,

          Really easy with regular expressions !

          So , assuming a simple list of filenames, with any extension, like below :

          Pride and Prejudice - Jane Austen.epub
          Moby Dick - Herman Melville.epub
          A Tale of Two Cities - Charles Dickens.epub
          
          • Open the Replace dialog ( Ctrl + H )

          • SEARCH (?-s)^(.+)(\x20-\x20)(.+)(\..+)

          • REPLACE ren "$0" "\3\2\1\4"

          • Tick the Wrap around option

          • Select the Regular expression search mode

          • Click, once, on the Replace all button

          You should get the expected result :

          ren "Pride and Prejudice - Jane Austen.epub" "Jane Austen - Pride and Prejudice.epub"
          ren "Moby Dick - Herman Melville.epub" "Herman Melville - Moby Dick.epub"
          ren "A Tale of Two Cities - Charles Dickens.epub" "Charles Dickens - A Tale of Two Cities.epub"
          

          Voila ;-))

          Best Regards,

          guy038

          Ron BallR 1 Reply Last reply Reply Quote 3
          • Ron BallR Offline
            Ron Ball @guy038
            last edited by

            @guy038 This is awesome! Thank you so much! It worked perfectly.

            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