Create REN Batch File?
-
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 DickensThis 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" -
@Ron-Ball said in Create REN Batch File?:
Pride and Prejudice - Jane Austen
Moby Dick - Herman Melville
A Tale of Two Cities - Charles DickensFrom 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.
-
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 aroundoption -
Select the
Regular expressionsearch mode -
Click, once, on the
Replace allbutton
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
-
-
@guy038 This is awesome! Thank you so much! It worked perfectly.
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