Book Title Caps - A Rename JavaScript

Book Title Capitalize - v1.0


Titles and topics normally only upper-case the 1st letter of the first word, and keep the rest of the line all lower-case.

But there is another way to capitalize titles, I am calling it: Book Title Capitalize, and this can be found on book or movie titles. Here the first letter of every word is upper-cased, excepting articles and prepositions that are all lower-case,

e.g. ThE end oF THE game.tXTThe End of the Game.txt

I use this style for all my mp3 files. And finally - a least for the file and folder names - this can be automated. It would be even better to be able to do this for ID3 tags in the mp3 files... but alas that must be for another day.


For more details see the comment header of the script. As you will read there are quite a things you can do with the script:

 *   ae_opus_book_title_caps.js     (Based by my UltraEdit JavaScript:
 *  -----------------------------               ae_book_title_capitalize.js)
 *      by AEon (C) 2008  
 *                                  Code Provided as is, use at your own risk.
 *  Creation Date:  10/23/2008
 *  Last Modified:  10/26/2008 v1.0
 *  Purpose: Capitalize selected file (folder) names into "Book Title" style:
 *           Upper-case the 1st letter of each word, but keep all articles
 *           and prepositions in lower case.
 *           E.g.:  "ThE end oF THE game.tXT"  ->  "The End of the Game.txt"
 *  Install: This Rename JavaScript is intended to be run from Opus v9.1+.
 *           Open advanced Rename dialog, set Old name to * and New name to *,
 *           turn on "Script mode", paste this code into the edit view,
 *           save under "Presets" as "Book Title Caps".
 *  Usage:   Select files and folders you want to capitalize, open Rename
 *           dialog, then run the "Book Title Caps" preset. Rename preview
 *           (Ctrl+W) will show the renamed files. And/or use the Test button!
 *  Note:    - Only key word (i.e. articles & prepositions) are lower cased.
 *             - Exception 1st word in file/folder name.
 *             - Exception 1st word *after* " - ", i.e. "10 - For Those.mp3"
 *           - For all other words *only* the 1st letter is upper-cased,
 *             this preserves e.g. "valid" all upper-case words!
 *           - Works on any number of files or folder names.
 *           - Words *need* to be separated by spaces or tabs or _.
 *             - Tabs (if present) and Underscores _ are replaced by spaces!
 *             - Multiple spaces are reduced to one space.
 *           - The file extensions are lower cased.
 *           - Special Case Delimiters () [] ... ,
 *             - Words starting with ( or [ after " - " are capped:
 *               "01 - (THE) blah" -> "01 - (The) Blah"
 *             - Words ending on ) or ] or , are properly cased:
 *               "01 - Blah (the end OF)" -> "01 - Blah (The End of)"
 *             - Words ending on ... are properly cased:
 *               "01 - Blah (the OF...)" -> "01 - Blah (The of...)"
 *          - User the global var switches to control script behavior.
 *  Tip:    - You can use all the "pre-rename" switches from the Rename dialog
 *            with the script, e.g. Modify capitalization, All Lower-case.
 *          - Use DOpus.OutputString("Text"); to write to Output window.


  • Upper-case the first letter or each word, excepting prepositions and articles.
  • Lower-case file extensions.
  • Special treatment of delimiters: ( ) [ ] ... ,
  • Special treatment of articles and prepositions after " - ", 1st letter is also upper-cased.
  • etc.


  • A few settings, i.e. replacement of underscores or the special treatment of words after " - " can be controlled via Global Variables in the script.
  • You can use the default rename features of in the Rename dialog to "pre-rename" the file/folder names, e.g. Modify capitalization, All Lower-case works nicely.
  • If you want to add more exceptions to the list of words that should always be/stay in lower-case, add them in the create_art_prep_array() function.
  • The JavaScript is extensively commented, so it should help those interested in JavaScript or in changing the code.




Should you be missing some feature, or find a bug, drop a line and I will look into it.

Hope the script is useful.


What you call Book Case, is actually called TitleCase. I wrote a script a long time ago which performs TitleCase renaming (amongst other things).

It's good to have a substantial JavaScript rename example (even if there is a big overlap with the TitleCase rename script).

Hmm... I read that TitleCase thread and looked into what your script was doing. It did do renaming but not what this script does. Unless you expanded it greatly and added features not mentioned in the first post.

Maybe I'm missing some things but the only thing I can see that it does which TitleCase doesn't is the [ ] and ( ) caps stuff.

It does everything I see listed in your script from memory. :slight_smile:

Still, as Leo says, it's useful to have a javascript version.

I re-checked the steve's code... indeed it pretty much does the same... I had not given the "Convert to true titlecase" enough credit.

BTW, comparing your list of lower-case articles and prepositions:

You additionally have: into, onto, it, is

Checking with

I seem to have missed "into" and "onto". On the other hand "is" and "it" seem to be a preference and not strictly "mandatory".

My code has these additionally:
[ul]"per", "so", "up", "via", "vs.", "nor", "out", "yet"[/ul]
Oh, well...

Hi AEon,

Could you add the ability to your script to rename

Test V5.6.0.txt


Test v5.6.0.txt