#1 Yesterday 01:30

Digidoc
Member
Registered: Yesterday
Posts: 4

Renaming ebook files

Greets and hello. I have many thousands of ebooks which need to be renamed. They are actually in this format:

A Change in Altitude - Anita Shreve.mobi
A Wedding in December_ A Novel - Anita Shreve.mobi
Fortune's rocks_ a novel - Anita Shreve.mobi
Gentlemen prefer blondes - Anita Loos.mobi
The Red Tent - Anita Diamant.mobi

Or: Title - Author First, {sometimes initials} Author Last.

I want to rename to this:

Shreve, Anita-A Change In Altitude.mobi
Shreve, Anita-A Wedding In December_A Novel.mobi
Shreve, Anita-Fortune's Rocks_A Novel.mobi
Loos, Anita-Gentlemen Prefer Blondes.mobi
Diamant, Anita-The Red Tent.mobi

Or: Author Last, Author First-Title.
----------------
I can capitalize each word.
I can change [ - ] to a single [-]
I can replace [_ ] to a single [-]
Is it possible to analyze the title, and rearrange as I have suggested? I have another 14,000 books to rename, so even if I can manage 1000 per month, this will take me a --very-- long time. Thoughts? Suggestions? (email is always welcome)

Perhaps each space in the original name could be a split point?
These split points could then be assigned numbers?
The name could then be arranged to put the last split first, followed by a comma, the second to last split point, followed by a [-] and then the remainder of the split points?

Last edited by Digidoc (Yesterday 02:25)

Offline

#2 Yesterday 17:54

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,521

Re: Renaming ebook files

You'll need the power of the Regular Expressions rule for this one.

Replace expression "^(.*)\s+-\s+(\S+)\s+(\S+)$" with "$3, $2-$1" (skip extension).

Note that this pattern assumes that the author name consists of exactly two words, no more, no less.

Offline

#3 Yesterday 19:00

eR@SeR
Senior Member
Registered: 2008-01-23
Posts: 359

Re: Renaming ebook files

Hello,

This RegEx rule include cases if there are 2, 3 or more words (initials as well) in author's name:

Replace expression "(.+) - ([^\s]+) (.+)" with "$3, $2-$1" (skip extension)

From:

A Change in Altitude - Anita Shreve.mobi
A Wedding in December_ A Novel - Anita Shreve.mobi
Fortune's rocks_ a novel - Anita Shreve.mobi
Gentlemen prefer blondes - Anita Loos.mobi
The Red Tent - Anita Diamant.mobi
The Hobbit and The Lord of the Rings - J.R.R. Tolkien.mobi
Extinction - Douglas J. Preston.mobi
One Hundred Years of Solitude - Gabriel García Márquez.mobi
Game of Thrones - George Raymond Richard Martin

To:

Shreve, Anita-A Change in Altitude.mobi
Shreve, Anita-A Wedding in December_ A Novel.mobi
Shreve, Anita-Fortune's rocks_ a novel.mobi
Loos, Anita-Gentlemen prefer blondes.mobi
Diamant, Anita-The Red Tent.mobi
Tolkien, J.R.R.-The Hobbit and The Lord of the Rings.mobi
J. Preston, Douglas-Extinction.mobi
García Márquez, Gabriel-One Hundred Years of Solitude.mobi
Raymond Richard Martin, George-Game of Thrones

Addition: If you want to have Author Last, Author First {sometimes 2+ words, initials} as a result use:

Replace expression "(.+) - (.+) (.+)" with "$3, $2-$1" (skip extension)

Offline

#4 Today 11:20

Digidoc
Member
Registered: Yesterday
Posts: 4

Re: Renaming ebook files

Wow, this works great. This will save me hundreds of hours automating my naming process. I used it on a folder containing 94 books. The only ones who messed up were: 2001 A Space Odyssey - Arthur C. Clark; it came out as C Clark, Arthur-2001 A Space Odyssey.

I think this has to do with the initials containing [.] or not.

Offline

#5 Today 19:58

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,521

Re: Renaming ebook files

You can handle it with a second rule to rearrange 2-token and 3-token authors separately:

1) Replace expression "^(.*)\s+-\s+(\S+)\s+(\S+)$" with "$3, $2-$1" (skip extension)
2) Replace expression "^(.*)\s+-\s+(\S+)\s+(\S+)\s+(\S+)$" with "$3 $4, $2-$1" (skip extension)

This works on spaces and non-space sequences, so dots don't be a problem.

Rearrange the replacement pattern "$3 $4, $2-$1" to get "C. Clark, Arthur" in a different order.

Input:

Shreve, Anita-A Change in Altitude.mobi
Shreve, Anita-A Wedding in December_ A Novel.mobi
Shreve, Anita-Fortune's rocks_ a novel.mobi
Loos, Anita-Gentlemen prefer blondes.mobi
Diamant, Anita-The Red Tent.mobi
C. Clark, Arthur-2001 A Space Odyssey.mobi

Output:

Shreve, Anita-A Change in Altitude.mobi
Shreve, Anita-A Wedding in December_ A Novel.mobi
Shreve, Anita-Fortune's rocks_ a novel.mobi
Loos, Anita-Gentlemen prefer blondes.mobi
Diamant, Anita-The Red Tent.mobi
Clark C., Arthur-2001 A Space Odyssey.mobi

Offline

Board footer

Powered by FluxBB