06-12-2011, 07:39 PM | #1 |
Quack! Quack!
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
|
Regex: File Renaming Pre-Import & Importing
**Note: If this thread interests you keep checking back I am going to keep updating it and adding to it. The last add will be in green. Red is for incompletes. Blue is for Donations. Last add - 6/14/2011 03:31:47 (UTC)
Here is some very useful regex for use with Flash Renamer Pre-Import to Calibre followed up by Calibre Import Scripts to be used after file clean up. Flash Renamer is the ultimate in renaming files quickly in bulk. These can be used with other bulk renaming software as well but you might have to tweek. I am going to continue to add and edit this thread until it consists of a fairly large library of scripts for file renaming and calibre to assist people trying to import/convert large collections of books to/in calibre. RegEx for use in Flash Renamer or other Bulk File Renamer INFO====>Swap Lastname, Firstname if in front of a title or series preceding a dash(-) EXAMPLE=>Martin, George RR - Ice & Fire 01 - Game of Thrones.epub RESULT==>George RR Martin - Ice & Fire 01 - Game of Thrones.epub FIND====>^(\w+), *([\w \.]+)[ ]+-[ ]*(.*) REPLACE=>$2 $1 - $3 OR======>Depending on what program your using REPLACE=>\2 \1 - \3 INFO====>Swap Lastname, Firstname & Lastname, Firstname when in front of a dash (-) EXAMPLE=>Martin, George RR & Kirk, James T - Ice & Fire 01 - Game of Thrones.epub RESULT==>George RR Martin & James T Kirk - Ice & Fire 01 - Game of Thrones.epub FIND====>([^,]*), ([^&]*)& ([^,]*),([^-]*)- REPLACE=>$2$1 &$4$3 - INFO====>Swap Lastname, Firstname and Lastname, Firstname when in front of a dash (-) EXAMPLE=>Martin, George RR and Kirk, James T - Ice & Fire 01 - Game of Thrones.epub RESULT==>George RR Martin & James T Kirk - Ice & Fire 01 - Game of Thrones.epub FIND====>([^,]*), ([^&]*)and ([^,]*),([^-]*)- REPLACE=>$2$1 &$4$3 - INFO====>Title - Author Swap EXAMPLE=>Game of Thrones - George RR Martin.epub RESULT==>George RR Martin - Game of Thrones.epub FIND====>(.*) - (.*) REPLACE=>$2 - $1 NOTE===>Simple swap... If tried on a 3 part 1-2-3 it will change to 3-1-2; if run again it will go to 2-3-1 and once more back to 1-2-3 it also carries anything else in brackets along with part 3. INFO====>Title - Author Swap /w Series Info in the center EXAMPLE=>Game of Thrones - Ice & Fire 01 - George RR Martin.epub RESULT==>George RR Martin - Ice & Fire 01 - Game of Thrones.epub FIND====>(.*) - (.*) - (.*) REPLACE=>$3 - $2 - $1 NOTE===>This swap will carry any brackets in position 3 along with it. This can be modified to swap the three parts interchangeably by changing the order of the numbers to handle other variations. Other variations will cycle. For example if you change the replace to $3 - 2$ - $1 Then A-S-T would change to T-A-S when run again it would change to S-T-A and then back to A-S-T. So to change any position you really need a A--T Swap and then another that will cycle. You can then with a few runs get the correct order INFO====>Title - Author Swap /w Series Info, Version, and any other info in brackets left in position. File can be 2 part (T - A) or 3 part ( T - S - A) with or without extra bracketed info. EXAMPLE=>Game of Thrones - [Ice & Fire 01] - (unabridged) George RR Martin (v1.01) (epub).epub RESULT==>George RR Martin - [Ice & Fire 01] - (unabridged) Game of Thrones (v1.01) (epub).epub FIND====>([^-]*) - ([^-]* - )?([^(]*)( \(.*\))? REPLACE=>$3-$2$1 $4 NOTE===>This is the end all be all of Author/Title swaps. It can be used for files with just Author and Title or with Files with Author, Series, Titles and both of those are with or with out other bracketed information leaving those in place. Because of this I had to allow enough spacing for 2 part swaps. That means there is an extra space in the 3 part swap. So you will need to do a Trim Spaces afterwords or you can save this for 2 part swaps and then adjust the space in the replace and save another for the 3 part swaps. ** You will need to TRIM SPACES afterwards for other software that doesn't disregard the extension it is: FIND====>([^-]*) - ([^-]* - )?([^(]*)( \(.*\))?(\.[^(.]*) REPLACE=> \3 - \2\1\4\5 INFO====>Change Dots into Spaces unless in Numbers EXAMPLE=>George.R.R.Martin.-.Ice.&.Fire.01.-.Game.of.Thrones.(v1.01).epub RESULT==>George R R Martin - Ice & Fire 01 - Game of Thrones (v1.01).epub FIND====>Under Construction REPLACE=>Under Construction NOTE===>Haven't worked it out yet for flash renamer Other tools: Find=====>(.*)(([^0-9])\.|\.([^0-9]))(.*\..*)# REPLACE==>\1\3 \4\5 IMPORT SCRIPTS FOR CALIBRE IMPORT==>Import "Author - Series Series_Index - Title" while removing brackets in series & deleting anything in brackets in the title CALIBRE=>^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^\]{[()]+\w) BEFORE==>George RR Martin - [Ice & Fire 01] - Game of Thrones [unabridged](v5.0)(epub).epub AFTER===>George RR Martin - Ice & Fire 01 - Game of Thrones.epub Donated by Debby - *haven't finished testing myself so i can't fill in output or what it does with bracketed info. Will test soon. Many thanks to Debby for the contribution of the spreadsheet she sent over. IMPORT==>LN, FN - [Series #] - Title (swaps lastname, firstname) CALIBRE=>^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^\]{[()]+\w) INPUT===>Clancy, Tom Smith - [Jack Ryan Universe 01] - Without Remorse.pdf OUTPUT==>Tom Smith Clancy - [Jack Ryan Universe 01]] - Without Remorse.pdf IMPORT==>FN LN (Series #) Title CALIBRE=>(?P<author>([^\-_\[\(]+))\((?P<series>[^_0-9-]*)(?P<series_index>[0-9]*)\)(?P<title>([^_\[\(]+)) INPUT===>Laura Wilder (01) Little house.pdf OUTPUT==> IMPORT==>Series Name - Title , Title # - Author CALIBRE=>^((?P<series>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?((?P<title>[^0-9\-]+)(\s*-\s*)?(?P<series_index>[0-9.]+)\s*-\s*)?(?P<author>[^\-_0-9]+) INPUT===>Jack Ryan Universe - Without Remorse 01 - Tom Clancy.lit OUTPUT==> IMPORT==>Series # - Title - LN _ FN (Swaps Lastname, First Name) CALIBRE=>^((?P<nada>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?((?P<series>[^0-9\-]+)(\s*-\s*)?(?P<series_index>[0-9.]+)\s*-\s*)?(?P<title>[^\-_0-9]+)- (?P<author>[^-]+) INPUT===>Alex Cross 1 - Along Came a Spider - Patterson,James.epub OUTPUT==> IMPORT==>Author name - Book title, Series #.format CALIBRE=>(?P<author>[^_]+) - (?P<series>.+)( |(, Book #))(?P<series_index>[0-9]+) - (?P<title>.+) INPUT===>Tom Clancy - Jack Ryan Universe #01 - Without Remorse.pdf OUTPUT==> IMPORT==>Author name - Book title.format CALIBRE=>^((?P<author>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?((?P<series>[^0-9\-]+)(\s*-\s*)?( |(, Book #))(?P<series_index>[0-9.]+)\s*-\s*)?(?P<title>[^\-_0-9]+) INPUT===>Tom Clancy - With our Remorse.txt OUTPUT==> IMPORT==>Title (Series #) - FN LN CALIBRE=>(?P<title>.+) \((?P<series>[^_0-9-]*) (?P<series_index>[0-9]*)\) - (?P<author>.+) INPUT===>Ark Angel (Alex Rider 06) - Anthony Horwortiz.lrf OUTPUT==> IMPORT==>Author - Title - Series 01 CALIBRE=>(?P<author>[^_-]+) -?\s*(?P<title>[^_0-9-\[\(]*)[\[\(]?(?P<series_index>[0-9]*)[\]\)]?\s*-\s*(?P<series>[^_].+) ? INPUT===>Tom Clancy - Without Remorse - Jack Ryan Universe 01.pdf OUTPUT==> PREFERENCES=>Remove Page Numbers CALIBRE=====>Page\s+\w+ PREFERENCES=>Remove Amber Lit CALIBRE=====>(<A name=\d+>\s*</a>)?\s*(<[biu][^>]*>)?\s*Generated\s+by\s+(ABC)?\s+Amber[^<]*(<a\shref=.*?processtext.*?>)?\s*(.*?processtext. *?</a>)?(</[ibu]>)?\s*(<br>\s*)? IMPORT==>Import "Author - Series Series_Index - Title" while removing brackets in series & leaving anything in brackets in the title like version info CALIBRE=>^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^-]+) BEFORE==>George RR Martin - [Ice & Fire 01] - Game of Thrones [unabridged](v5.0)(epub).epub AFTER===>George RR Martin - Ice & Fire 01 - Game of Thrones [unabridged](v5.0)(epub).epub NOTE====>I would clean the file of anthing you dont want in the title section before import so you only get what you want there; the next script is for taking care of that. This is for cleaning up files of all bracketed information other than version information pre-import to calibre. These commands can be strung together in a preset batch command and run all together at once in flash renamer rather than sepperatly although thats how I have it listed. This is for running against multiple files at the same time like huge collections. *note: i am going to use the tilde "~" to represent a white space so you will have to replace it with a space. **This changes all brackets to rounded** FIND====>[ REPLACE=>( Run Rename FIND====>] REPLACE=>) Run Rename FIND====>{ REPLACE=>( Run Rename FIND====>} REPLACE=>) Trim Spaces (a simple button press in flash renamer) **This removes brackets from around series without deleting series - remember to remove tildes the represent space** FIND====>-~( REPLACE=>-~ Run Rename FIND====>)~- REPLACE=>~- Run Rename **Check the Regex Box- This Changes the Brackets around version info to square brackets and leaves all others rounded** FIND====>(.+)\((v.+?)\)(.*) REPLACE=>$1[$2]$3 **Uncheck regex Box - This is a wild card it deletes all rounded brackets and whatever they contain** FIND====>(*) REPLACE=> Trim Spaces **This changes the square brackets back to rounded in version info** FIND====>(.+)\[(.+)](.*) REPLACE=>$1($2) Trim Spaces Now the file that looked like this: George RR Martin - [Ice & Fire 01] - Game of Thrones [unabridged](v5.0)(epub).epub Will Look Like this: George RR Martin - Ice & Fire 01 - Game of Thrones(v5.0).epub You can then use this calibre import and keep version info in title: IMPORT==>Import "Author - Series Series_Index - Title" while removing brackets in series & leaving anything in brackets in the title like version info CALIBRE=>^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^-]+) (to be continued) (anyone else wanting to add to this thread with useful script please do so) Last edited by penguinaka; 06-14-2011 at 11:39 PM. |
06-12-2011, 07:40 PM | #2 |
Quack! Quack!
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
|
Here is a renaming script that I created especially for ebook collectors. Its for use pre-calibre import. I hope you enjoy it! It's shaved hundreds of hours off my time working with my collection pre-import to calibre. Cheers!
BookCase (v6.7) - The Ultimate eBook File Renamer on Crack BookCase is a heavily modified TitleCase Plus VBscript that works as a button in Directory Opus (Directory Opus is a Windows Explorer Replacement... a trial version can be downloaded at http://www.gpsoft.com.au/ and the scripts to run in it that i created can be found at the end of the post). It is designed to do all your eBook file renaming in one button click. Everything that it can do is listed below and in the script all the options can be turned on or off so that you get the format that you desire. To give you an idea it can be run against 100,000 eBook files at once and will take approximately five minutes to complete. 1000 files and less its near instant. VERSION UPDATE (v6.7) Change List: 1. (request #1) added a remove bracketed version # feature (fBracketMagic2=True). The way this operates is it changes all brackets to round brackets then if fbraket=true then series brackets are removed if fbracket=false then series brackets are changed to square and then all rounded brackets are removed. If you use this feature then fBracketMagic1 should = false (i already have it set up for you) 2. (request #2) Swap title names that have ",the" ",a" and ",an" and the end of the title. I actually like this request i have the same thing in my library through out my books that i have been fixing by hand 3. (request #3) Swap lastname, firstname. this function was already built in and turned on as an option 4. (request #4) added AUTORENAME to script (if the file name already exists it renames the file to the same name with a "(1) at the end.) 5. (request #5) Turned off (commented out) the italian, spanish, french & german lower case exceptions which was giving you the W e B lower case in initals with initials that had "a" or "e" and a few others. 6. (request #6) Add a add brackets to series option and sub series option. 7. (request #7) Add a Zero padding in single digit #'s in series option BookCase Does the Following: All these are set as options that can be turned on or off by changing the value to "True" or "False" in the options area of the code its clearly marked if you edit the button. Just an example of what it can do: What format do you prefer? Just edit the bookcase button and set the options to your preference: Included in the zip is BookCase as a .orp file and additionally as a button. Also Including in the Zip is some other eBook Renaming Buttons. They are 3 Buttons... 2 of the buttons have a drop down with multiple buttons inside them. These Buttons and BookCase are on a Button Bar: Multiple Buttons File Contains: 1st Button: Trim - trims multiple spaces, leading and trailing 2nd Button: Replaces (multi button drop down) -1 Replaces underscores with a comma -2 Replaces underscores with spaces -3 Replace file name with folder name -4 Replace by with a dash -5 Append folder author name to beginning of file name + a dash separator -6 Removes everything but authors name on folders -7 Add series brackets -8 Remove desired # of charters from beginning of file name -9 Remove desired # of character from end of file name -10 Add extension info in brackets to end of file name -11 Dots to spaces except in numbers -12 Separate pushed together initials -13 Add dots to initials -14 Zero pad single digit numbers in series -15 Add "Series" to series that have just numbers and no series name. -16 Strip series out of file name -17 Remove a desired text -18 Insert a desired text 3rd Button: Swaps (multi button drop down) -1 Swaps lastname, firstnames of any type also multiples of them separated by & or and. -2 Swaps everything in a title on either side of a comma. -3 Swaps everything in a title on either side of a comma except brackets. -4 Swaps library order to regular title order excludes sentences that are not library order -5 Replace by with dash then do a author title swap -6 Replace underscore with a comma and do a Ln, Fn swap. -7 Swaps title series author (TSA) to (AST) and leaves bracketed info in place -8 Swaps (TAS) to (AST) and leaves bracketed info in place -9 Swaps (SAT) to (AST) and leaves bracketed info in place -10 Swaps (STA) to (AST) and leaves bracketed info in place -11 Swaps (ATS) to (AST) and leaves bracketed info in place The Buttons are in Text files just copy from <?xml version="1.0"?> to </button> in the files and paste it onto your bar while your in customization mode. There is a read first in the rar file which will explain more in depth how to install them onto the bar on opus... If you need further help feel free to pm me. Let me know what you think when you test drive them! Code:
http://www.filesonic.com/file/1578621124 Note on Typical Settings: 1. Keep all bracketed information regardless of what it is: fBracketMagic1 & fBracketMagic 2 should be false 2. Remove all bracketed info accept version info and series if bracketed: fBracketMagic1 = True and fBracketmMagic2 = False 3. Remove all Bracketed info but keep series info if bracketed: fBracketMagic1 = False abd fBracketMagic2 = True Last edited by penguinaka; 08-02-2011 at 06:27 PM. |
Advert | |
|
06-15-2011, 12:31 AM | #3 |
Nameless Being
|
Nice thread ty very much for going to the effort..
|
06-17-2011, 06:28 PM | #4 |
Connoisseur
Posts: 75
Karma: 600
Join Date: Jul 2008
Location: Depends Upon the Season.....
Device: Cybook, Sony & ipad
|
This is great! I love the explanations!
|
06-19-2011, 05:22 PM | #5 |
Junior Member
Posts: 4
Karma: 10
Join Date: Jun 2011
Device: none
|
Thanks! This is exactly what I was looking for when I registered 15 minutes ago.
|
Advert | |
|
06-19-2011, 05:26 PM | #6 |
total n00b
Posts: 6
Karma: 10
Join Date: Jun 2011
Location: City of Angels
Device: Kindle 3
|
Fantastic!
Don't understand a word of it yet but I know I need it for my mess of a collection that I want to get into Calibre soon! |
06-20-2011, 10:34 AM | #7 |
Addict
Posts: 288
Karma: 1003542
Join Date: May 2011
Device: Google Nexus 7 16GB
|
Looks great, I see that the Flash rename app, is a trial, how long does it last? = couldn't find that info on their site
I'm using the free "Bulk Rename Utility" at present, but always willing to try out others. |
06-24-2011, 12:59 AM | #8 | |
Nameless Being
|
Quote:
http://file-folder-ren.sourceforge.net/ its called metamorphose. Has anyone come across a re namer that will take the directory name and add it to the file name? Just wondering if there is something that could do that and how deep could it take directory names to add to file name.. eg folder = 2000 folder = john smith file name = this is my book end result file name = 200 - john smith - my book.epub |
|
06-24-2011, 10:40 AM | #9 | |
Well trained by Cats
Posts: 29,779
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
I just tried it. It has a learning curve BTW the template I showed might be what you want to use |
|
07-01-2011, 03:19 AM | #10 |
Nameless Being
|
thank you very much !!!!
As a by the by is anyone having a prob since last update of Calibre - it seems to crash when trying to search through database - maybe just me?.. Never had that issue before. Cheers |
08-02-2011, 04:26 PM | #11 | |
Quack! Quack!
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
|
Quote:
I also made another button that you can select a whole group of files click the button and it creates author name folders and then drops the files into the appropriate folder. Here: https://www.mobileread.com/forums/sho...37&postcount=2 Last edited by penguinaka; 08-02-2011 at 07:42 PM. |
|
08-03-2011, 11:19 AM | #12 |
Connoisseur
Posts: 52
Karma: 12
Join Date: Jul 2011
Device: none
|
pre-import rename
I use a program called Rename-it!. Also has regex support.
http://sourceforge.net/projects/rena...name-It!/3.32/ |
08-11-2011, 10:02 AM | #13 |
Nameless Being
|
Awesome ty very much - and thank you for the time and dedication to do the work you have... quick question - I've downloaded opus works without issue - 60 day trial is nice but a bummer.
How hard would it be to have your script work with totalcomander? the only nag screen totalcomander has is press button 1,2 or 3 for however long you may want to use it for. Totalcomander in my humble opinion is the go to file browser - has ftp a reasonably good renamer in it already but lacking the functions of better renamers. Twin view etc etc etc ... http://www.ghisler.com/ Regards and thank you for your efforts once again.. |
08-12-2011, 12:17 AM | #14 |
Quack! Quack!
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
|
I'm not sure about total commander never used it...but since the scripts are just accessing windows shell functions through vbscript if total commander allows that with a tweek or 2 it should work in it... if you have opus already installed customize the bar then edit the button.... you can then ctrl-a copy all the script out of the script field and move it over into commander. Don't ask me how to set it up in there since i'm unfamiliar with it... cheers!
|
08-12-2011, 10:03 AM | #15 |
Nameless Being
|
Hey thanks for the reply,
Had more of an opportunity to play with your script, absolutely brilliant.. what a time saver it is.. its almost as if you've read minds and common issues.. Thanks once again.. Will see if I can port your scripts to TotalComander - its worth a look if you like opus I think you may like it as well two very similar apps.. cheers... |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Importing RegEx Line | TheEldest | Calibre | 1 | 07-05-2011 10:18 PM |
Import files, regex question | al35 | Calibre | 0 | 03-22-2010 12:33 PM |
Renaming File Problem... | Howard098 | Sony Reader | 3 | 02-01-2010 10:57 PM |
importing html does not import images | reup | Calibre | 12 | 12-08-2009 08:52 PM |
regex Issue when Importing | river | Calibre | 3 | 06-16-2009 11:03 AM |