ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE. Software > Post New Requests Here

IDEA - how to capitalise the first word of every line

(1/4) > >>

I'm creating a hymn book.  The book I scanned and OCR'd had all the songs as blocks, with capitals only at the beginning of a sentence.
Whereas I want to put a capital at the start of every line.

There are just under a thousand songs so I don't want to do it by hand!!

Any ideas?  I've looked on line and can't find anything except via MS Word, which can be configured to do it after every carriage return.
But as far as I can see, only as you type.

Is there a way to replace every "carriage return" with "carriage return and capitalise the next letter"?

Hallo Stormproof!

Kingsoft writer may have some ways to help.

(P.S. these "fast posted screen shots" are from Chris Gingerich's NANY this year! This is what it's for!)

So suppose you have this hymn fragment etc.

oh lord
tell me to stay strong
let me hold to thy name

In Kingsoft Writer


Then you can experiment with the options.

So that hymn above becomes:

Oh lord
Tell me to stay strong
Let me hold to thy name

Or you can use Notepad++ (Freeware).

Notepad++ has a colum select mode (hold alt-key while selecting the appropriate text/columns). Then with the first column marked you can use menu TextFX->TextFX Characters->UPPERCASE.


There's a few sed answers with s/^\(.\)/\U\1/. GNU sed also has a \u directive that changes only the next letter to uppercase, so

sed 's/./\u&/'

Although if the first character on a line is a space, you won't see an uppercase letter, so

sed 's/[[:alpha:]]/\u&/'

--- End quote ---
from this page:

This is conducive to batch. Once you test and find it works as expected then you can just loop through all the files and save them to the same file name with an additional extension.  For example file.txt the output could be file.txt.cap or whatever.  Once you verify the output has no errors then you can just rename the output files back to the original names.

There are free sed implementations for Windows.  Which you want to use generally is determined by whether you wish to do any shell programming such as with bash shell.  Also some need to have bash set up because special characters can conflict with those in Windows command prompts.  It's often easier just to run a bash command prompt to do the stream editing.

This particular task can probably be done fairly easily using awk.  A 'nawk' (for new awk) executable may not need the bash environment.  I'm not sure as there have been several Windows releases and i'm sure some changes in the Linux tools ported.  Last time I really played with them was in XP.


[0] Message Index

[#] Next page

Go to full version