Run rename script on clipboard text?

I have a whole pile of text snippets that are in all lowercase which I need to change to sentence case. I thought maybe Opus could help with this?

Basically I'm thinking I could copy the text to the clipboard, hit a global hotkey, and magically Opus will grab the text from the clipboard, fix it, then put it back on the clipboard for me to paste again.

Does this sound possible? Can somebody help me with the code?

If it's not possible, does anybody know a good way to accomplish this?

Many thanks!

There is a whole section of this forum dedicated to "rename scripting".

The bit you need is:

"Rename CASE=allwords,upper"

This probably came from the set of scripts available in the discussion:

Titlecase

resource.dopus.com/viewtopic.php ... highlight=

Visit that section, spend a bit of time wandering around and you will find this and many more.

The message in question has some very useful "worked examples". When you have got them you can then work out how to turn them into buttons or, as I prefer it, context menus.

Thanks for the reply, but I think you misunderstood. I know how to do everything you described. I have a special 'rename' menu in my default lister filled with scripts that I either found here or wrote myself.

What I'm asking is if it's possible to 'abuse' the rename scripting capabilities of Opus to run the script on the contents of the clipboard as I described in my original post.

Perhaps I should describe my needs a bit better. I'm currently using a plugin for foobar2000 to grab lyrics for all my music. Half the time, the lyrics it finds are all lower case. I'm very compulsive about things like this, so I want to change the lyrics I grab to sentence case (simply put, the first letter of each sentence is capitalized).

What I'm hoping is that I can have foobar grab the lyrics, then from the tagging dialog, I can highlight the offending text, copy it to the clipboard, then hit a global hotkey to have Opus run a rename script on the copied text, and put it back on the clipboard when it's done so i can paste it back into foobar.

I can setup the rename script, that's no problem. It's the rest I'm unsure about!

You could do this using an Opus rename script but I think in this case, unless you're a VBScript/Javascript wizard, it'd be a lot easier to use a text editor. It's all being done on the clipboard in memory, with no files involved, so Opus isn't providing much other than an easy way to trigger a global hotkey.

You could instead have a global hotkey which opens a new text editor window and then use a few simple keystrokes to do the job.

e.g. With TextPad (since it's what I have installed):

Ctrl-V, Ctrl-A, Ctrl-Shift-K, Ctrl-C.

(Ctrl-Shift-K is the hotkey for Edit -> Change Case -> Sentence Case)

Any good text editor should let you do that, though the Sentence Case hotkey/menu item will vary.

Going back to the idea of doing it via VBScript/rename scripts:

It's a pain to get a large amount of clipboard text into VBScript. You either have to pass it as an argument, which has length limits, or you have to use the IE COM object to grab it, which creates an annoying security prompt you have to click.

Since there isn't a good standard "set clipboard" object either, to set the clipboard text you have to call out to either Opus's Clipboard SET command or something like my SetClip.exe.

It is possible to do in scripts, and some of the rename script examples do do it, but in this case where you're not passing any files to the script, I think it'd be easier just to use an editor...

If you do want to go the script route and need help writing it, though, let me know and I can point you to the most useful examples.

Just saw your reply... I guess using a text editor would be a pain if you're going to be doing it on lots of small pieces of text. But so would having an IE security prompt appear every time you ran the script. :slight_smile:

I did a search for "sentence case clipboard" and found one tool that looks like it'll do it, but I wasn't sure about the two download sites it was on and didn't want to risk a virus trying it out...

It'd probably be pretty easy to write a little tool to do this in C# as .Net has a built-in sentence-case function as I remember...

Thanks a lot for the detailed reply, Leo.

I've never used an extended text editor because I don't do any programming, so I wasn't aware that some of them actually have this function built right in. TextPad looks a bit complex, so I'll look around for a simpler (freeware!) one that might do the job. Once I've found it, I can probably work up an AHK script to do the work.

I was just testing the waters here. I didn't have any idea it would be so complicated to do this with Opus. But now I know, and can work in a different direction.

Thanks again!

Sorry for the double-post, I don't see an Edit button...

I never imagined would be a dedicated app to do this, but I'll google around and see what I can find! If there's nothing good, and if it really is a simple matter to write something like this, I'll post a request over at Donation Coder. It's about time I gave them some money anyway :slight_smile:

Thanks again!

Couldn't find such function. Anyway, I coded the tool in C# just as Leo mentioned. Simply put a text into the clipborad and run the EXE. It will capitalize the first occurence of a letter between 'A' and 'z' after a delimiter like . ! ? or : and puts the result back to the clipboard.

You will need .NET framework v2.0 installed on your computer.

Give it a try.

W@ng
SentenceCaseClip.zip (2.63 KB)

That works great, thank you very much!