Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Create REN Batch File?

    Help wanted · · · – – – · · ·
    rename batch file filenames
    3
    4
    72
    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 Ball
      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"
      
      Ekopalypse 1 Reply Last reply Reply Quote 0
      • Ekopalypse
        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
        • guy038
          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 Ball 1 Reply Last reply Reply Quote 3
          • Ron Ball
            Ron Ball @guy038 last edited by

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

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors