Automatic case changing

Posted: 08-26-2004, 02:25 PM
Does anyone know a way (have a script) for changing case according to
character or paragraph style?

I am importing a lot of text with headings in caps, and want to be able to
change them to sentance case.

k


Reply With Quote

Responses to "Automatic case changing"

Dave_Saunders@adobeforums.com
Guest
Posts: n/a
 
Re: Automatic case changing
Posted: 08-26-2004, 02:42 PM
Here you go:

if (app.documents.length != 0) {
myDoc = app.activeDocument;
myStyles = ["Head","Subhead"];
app.findPreferences = null;
app.changePreferences = null;
for (i=0; myStyles.length>i; i++) {
try {
myStyle = myDoc.paragraphStyles.item(myStyles[i]);
myStyle.name;
}catch(e){
// Ignore missing styles
continue;
}
myFinds = myDoc.search("",false,false,undefined,{appliedPara graphStyle:myStyle});
for (j=0; myFinds.length>j; j++) {
myFinds[j].changecase(ChangecaseMode.sentencecase);
}
}
}

Just replace or add style names to the third line. The script ignores any style names that are not present in the document.

Dave
Reply With Quote
Ken_Grace@adobeforums.com
Guest
Posts: n/a
 
Re: Automatic case changing
Posted: 08-26-2004, 02:53 PM
Brilliant. Thanks Dave. I'll remember this script (!).

k


Reply With Quote
Dave_Saunders@adobeforums.com
Guest
Posts: n/a
 
Re: Automatic case changing
Posted: 08-26-2004, 02:55 PM
I guess I should take some steps to make sure I do. I just banged it out so at the moment this is the only place it exists.

Dave
Reply With Quote
Ken_Grace@adobeforums.com
Guest
Posts: n/a
 
Re: Automatic case changing
Posted: 08-26-2004, 04:24 PM
I would think it quite useful in a wider context, like on Exchange. What
would make it really user friendly would be to add an input box with a drop
down of paragraph/character styles in the document, story/document/selection
wide selection and the change case options.

What, of course, would ultimately be neater would be if Adobe were to put
change case options in find/replace.

Thanks again Dave, that's going to save me a lot of time.

k


Reply With Quote
Dave_Saunders@adobeforums.com
Guest
Posts: n/a
 
Re: Automatic case changing
Posted: 08-26-2004, 04:35 PM
And then there's the concepts of "smart" sentence case and "smart" title case where selected words can be listed for exceptional treatment (remain all-caps in the first case; go to all lowercase in the second).

Perhaps, rather than a dialog box, if the script took instructions from an editable text file. I don't like dialog boxes if I can help them, but I also don't like having to tell people to edit scripts in order to use them.

Not that I have anything against the Exchange, but I'm assembling a page of useful utitlities on my web site. I'll work up a more useful version of this script and add it. The page is here: Informal Utilities for Download <http://pdsassoc.com/index.php?Nav=downssub&Ban=InformalUtilitiesForDow nload&Info=downloads/index.php>.

Dave
Reply With Quote
mikewitherell_at_jetsetcom_dot_net
Guest
Posts: n/a
 
Re: Automatic case changing
Posted: 08-26-2004, 04:38 PM
Dave,

Is that saved as a .js javascript textfile?

Thanks,

Mike Witherell in Washington DC
Reply With Quote
Dave_Saunders@adobeforums.com
Guest
Posts: n/a
 
Re: Automatic case changing
Posted: 08-26-2004, 04:51 PM
Mike,

Yes.

Help me brainstorm. How about a text file that looks like this:

Paragraph Styles
name1
name2

Character Styles
name1
name2

Internal Caps
InDesign
PageMaker
McDonald's

Lowercase Exceptions
and
by
with
for
etc.

Uppercase Exceptions
BBC
IBM
etc.

This file would sit in the same folder as the smart case changer -- except I'm inclined to think I need two script: smart Title case and smart Sentence case.

Each script would work like this:

If you have a text selection then the script ignores the style names and does its thing on the selection, applying the other lists as appropriate.

If you have no names listed under the styles, then it will complain if there is no selection. But if you have names there and no text selection, it will apply its changes to the designated styles, if they are used in your document.

What if you have a text frame selected? How about a single insertion point?

For the former, I could apply the style changes to only the text frame (or to its parent story). For the later, the style changes could be applied to the parent story.

Perhaps in this odd-ball cases, the script should check with the user before doing anything or there could even be a check with user directive in the text file.

What do you think?

Dave
Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing text without changing frames. Jose Olivas Macromedia Flash 1 03-21-2005 10:36 AM
URL case is adjusted? Paul ASP.NET Web Services 2 03-05-2004 09:48 AM
#23026 [Com]: Make Zend case-sensitive (classes, functions, remove case-insensitive) nvivo at mandic dot com dot br PHP Development 0 10-19-2003 12:17 PM
Changing case of the first letter of words in string Bis PERL Beginners 6 08-25-2003 09:56 PM
CASE statement and CONTAINS steve Macromedia Director Lingo 2 07-31-2003 12:12 AM