Rearranging file name with regular expressions
I have a bunch of ebooks that I want to rearrange the file names of. Currently, they are arranged like this...
Alexandra Moody - Wrong Costar_ A YA Enemies-to-Lovers Romance (The Wrong Match Book 2), The.mobi
And I want them to look like this...
Alexandra Moody - The Wrong Match Book 2 - Wrong Costar- A YA Enemies-to-Lovers Romance, The.mobi
In other words, author's name first, series name and book number (the part in parentheses) second, and then the book title. (Also, I want to change the underscore after 'Costar' to a hyphen, but this can easily be done in a separate replace command... it doesn't have to be done in the same step.)
I know the best way to accomplish this is probably with a replace command and regular expressions, but I can't for the life of me figure out what expressions to use to accomplish this. Can anyone help? Thanks in advance!
Alexandra Moody - Wrong Costar_ A YA Enemies-to-Lovers Romance (The Wrong Match Book 2), The.mobi
And I want them to look like this...
Alexandra Moody - The Wrong Match Book 2 - Wrong Costar- A YA Enemies-to-Lovers Romance, The.mobi
In other words, author's name first, series name and book number (the part in parentheses) second, and then the book title. (Also, I want to change the underscore after 'Costar' to a hyphen, but this can easily be done in a separate replace command... it doesn't have to be done in the same step.)
I know the best way to accomplish this is probably with a replace command and regular expressions, but I can't for the life of me figure out what expressions to use to accomplish this. Can anyone help? Thanks in advance!
Reply to #1:
Good morning Delusion
Your are right. This can be done with the Replace method and regular expressions.
REPLACE: (\w.*) - (\w.*)_ (\w.*) \((\w.*)\)
REPLACE WITH: $1 - $4 - $2 - $3
As you can see i have divided it into blocks of text and then I have rearranged it with replace method
I hope I have helped you.
Miguel
Good morning Delusion
Your are right. This can be done with the Replace method and regular expressions.
REPLACE: (\w.*) - (\w.*)_ (\w.*) \((\w.*)\)
REPLACE WITH: $1 - $4 - $2 - $3
As you can see i have divided it into blocks of text and then I have rearranged it with replace method
I hope I have helped you.
Miguel
Reply to #2:
Worked like a charm. Thanks!
Worked like a charm. Thanks!
Reply to #2:
I Have Files In Format of Like This which need to be replace like as i shown in before and after
Old Formate
yyyy. Filename - HindiDubbed - 720p
yyyy. Filename - HindiDubbed - 1080p
New Format
Filename - yyyy - HindiDubbed - 720
Filename - yyyy - HindiDubbed - 1080p
can you please help me how to write regular expression cause it won't happend by move or replace method simply
I Have Files In Format of Like This which need to be replace like as i shown in before and after
Old Formate
yyyy. Filename - HindiDubbed - 720p
yyyy. Filename - HindiDubbed - 1080p
New Format
Filename - yyyy - HindiDubbed - 720
Filename - yyyy - HindiDubbed - 1080p
can you please help me how to write regular expression cause it won't happend by move or replace method simply
Reply to #4:
Hi Aija,
This will probably do it, depending on what's in the "Filename" part of your names. If there's a dash "-" in the filename part it may not work. If you have problems and need more help just include a representative sample of actual filenames.
REPLACE method:
Replace: ([\d]{4})\. ([^-]+)
Replace with: $2 - $1
(there's a space after the "$1")
Occurrence: All
Case sens.: (doesn't matter)
Use regular expressions: CHECKED
Apply to: Name
Screenshot: https://drive.google.com/file/d/1wdJz-QsUjB9oquPY8TtgYbiVhqw nt1KG/view?usp=sharing
Best,
DF
EDIT: For future reference, it's probably better to start a new thread with a very specific subject line. END EDIT
Hi Aija,
This will probably do it, depending on what's in the "Filename" part of your names. If there's a dash "-" in the filename part it may not work. If you have problems and need more help just include a representative sample of actual filenames.
REPLACE method:
Replace: ([\d]{4})\. ([^-]+)
Replace with: $2 - $1
(there's a space after the "$1")
Occurrence: All
Case sens.: (doesn't matter)
Use regular expressions: CHECKED
Apply to: Name
Screenshot: https://drive.google.com/file/d/1wdJz-QsUjB9oquPY8TtgYbiVhqw nt1KG/view?usp=sharing
Best,
DF
EDIT: For future reference, it's probably better to start a new thread with a very specific subject line. END EDIT
Reply to #2:
Please help! How would I do it to rearrange a name like this:
current
mov_2024_12_02_top_freeze_mica_agent
desired
mica_agent_top_freeze_mov_2024_12_02
;
Please help! How would I do it to rearrange a name like this:
current
mov_2024_12_02_top_freeze_mica_agent
desired
mica_agent_top_freeze_mov_2024_12_02
;
Reply to #6:
Hello Franklin,
I'm starting a new thread for your question, as you should have, because (1) you should always do that when you are asking a new question, and (2) I suspect the answer I'm going to give is not the end of the discussion. Also, please edit out any extra newlines in your posts.
Not trying to be rude, just trying to make this forum better and more responsive.
Thanks,
DF
Hello Franklin,
I'm starting a new thread for your question, as you should have, because (1) you should always do that when you are asking a new question, and (2) I suspect the answer I'm going to give is not the end of the discussion. Also, please edit out any extra newlines in your posts.
Not trying to be rude, just trying to make this forum better and more responsive.
Thanks,
DF
Reply to #4:
S00.E00 - dd.mm.yyyy - Actor 1 - Movie Title - [ Genre ]
S00.E00 - dd.mm.yyyy - Actor 1 - Actor 2 - Movie Title - [ Genre ]
note: model some times more than one
I need below format instead of above format !!
S00.E00 - dd.mm.yyyy - Movie Title - Actor 1 - Actor 2 - [ Genre ]
S00.E00 - dd.mm.yyyy - Actor 1 - Movie Title - [ Genre ]
S00.E00 - dd.mm.yyyy - Actor 1 - Actor 2 - Movie Title - [ Genre ]
note: model some times more than one
I need below format instead of above format !!
S00.E00 - dd.mm.yyyy - Movie Title - Actor 1 - Actor 2 - [ Genre ]
Reply to #8:
Hi AUA,
I'm going to start a new thread to answer your question. It's easier than scrolling.
Best,
DF
Hi AUA,
I'm going to start a new thread to answer your question. It's easier than scrolling.
Best,
DF