Small feature request: Text Format to uppercase first letter

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Currently the supported text formats for transforming text in actions are "No change", "Title Case", "lowercase", "UPPERCASE". I'd like to suggest to add an option which uppercases the first letter only.

In my native language (Dutch) it's uncommon to Title Case Every Word In The Sentence. Instead it's very common to only Uppercase the first letter of a sentence.

I know it's possible to make a small script which will do the same, but I guess it's not a major change in the Text Format menu.
dennisvz
 
Posts: 2
Joined: Sat Sep 08, 2018 5:19 am

Will consider it. Can you provide some real world example where you would need this?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Well, recently I made a rule which extracts the subject of a company generated pdf file. Unfortunately, they don't start this line with a capital letter. They completely write it in lowercase.

I'm using this piece of text to compose a target file name to rename this file to (the source file name has a long unreadable string of digits). I'd like to have that first letter capitalized.
dennisvz
 
Posts: 2
Joined: Sat Sep 08, 2018 5:19 am

One thing you can try now is to use to custom attributes, instead of one, to match that line. Have the first one match the first word, and the second one to match the rest of the line. That way, you can then capitalize that first word separate from the rest.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

dennisvz wrote:Currently the supported text formats for transforming text in actions are "No change", "Title Case", "lowercase", "UPPERCASE". I'd like to suggest to add an option which uppercases the first letter only.

In my native language (Dutch) it's uncommon to Title Case Every Word In The Sentence. Instead it's very common to only Uppercase the first letter of a sentence.

I know it's possible to make a small script which will do the same, but I guess it's not a major change in the Text Format menu.


I use perl in a shell script in TextExpander to do it. But maybe it can be adapted to Hazel? (Credit to Though Asylum for this. If you want more like it, check them out.

http://www.thoughtasylum.com/blog/2011/ ... -case.html

#!/usr/bin/perl -w

#Initialise
use strict;
my($text);

#Get the text from the clipboard
$text =`pbpaste`;

#Convert the text to lower case
$text ="\L$text";

#Convert the first character of each word to upper case
$text =~ s/ ((^\w)|(\s\w))/\U$1/xg;

#Output the text
print $text;
Zathras
 
Posts: 2
Joined: Tue Nov 21, 2017 2:05 pm

You'd need to call that from an AppleScript as there's no way for shellscripts to pass anything back to Hazel. Also, you'd need to set up an input attribute and operate on that instead of the pasteboard.

Ultimately, it might be better to use the method I already described.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion