Title Case and Sentence Case "style"

393 views
Skip to first unread message

Mindy

unread,
Sep 7, 2011, 4:37:25 PM9/7/11
to indesi...@googlegroups.com
Hi all,

I'm working in CS4 and have a series of titles that the client would like to change to sentence case, instead of title case, but only for a portion of the publication. Is there a script that can perform that task on a selection (the titles are currently in tables).

It's only a few pages, so I can change them manually, but thought there might be a more efficient way to proceed.

Thanks.
Mindy

Roy McCoy

unread,
Sep 7, 2011, 6:49:58 PM9/7/11
to indesi...@googlegroups.com
Mindy wrote:

> I'm working in CS4 and have a series of titles that the client would like to change to sentence case, instead of title case, but only for a portion of the publication. Is there a script that can perform that task on a selection (the titles are currently in tables).
>
> It's only a few pages, so I can change them manually, but thought there might be a more efficient way to proceed.

If you were never going to want to script finding and changing again, the efficiency would kick in only on a job that was going to be repeated. It wouldn't even kick in on a longer job, since it's as easy or at least about as easy to f&c a list on a longer doc as on a shorter one. But you would do well to treat the present occasion as a learning exercise, and I think that's what you want to do even though you don't say so exactly.

Yes, there is such a script, but you should adopt the attitude that you can write your own f&c scripts since it really is relatively easy to do so - also because at some point or points you'll very likely have to. The basic script you want came with CS4 in its Scripts folder, I think, and is called "FindChangeByList". There should be a folder with this called "FindChangeSupport". I don't have my original CS4 scripts and so am not sure about everything, but I suppose you should make a copy of a "FindChangeList.txt" file in that folder, rename the file and take it from there. As the commented content of this file explains, you need to have this file contain a list in the format

findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description

You'll probably want text as the findType in all your list elements.

If the titles are unique and don't appear other than as titles within the selection, findProperties and changeProperties can be as simple as

{find what:"Title To Be Changed"}

and

{change to:"Title to be changed"}

respectively.

I'm not sure you need any particular settings for findChangeOptions, but you need to have something inside the curly braces there so you can just leave the default ones.

The description isn't very important in this case, so you can just put some kind of filler there, like for example

no description

When you have that list saved in a text file in the FindChangeSuport folder (technically it can be anywhere, I think, but you'll find it less confusing to keep all these f&c list files in the same place), you're all set. Make your selection, run the script, select your list file when prompted, and it should work. I made a test ID file containing "Title To Be Changed" and ran the FindChangeByList script selecting a text file containing:

text<tab>{find what:"Title To Be Changed"}<tab>{change to:"Title to be changed"}<tab>{include footnotes:true}<tab>no description

This changed the selected text to "Title to be changed".

Other people have posted similar tutorials about this script, so it may be that I should have looked for one of those and referred you to it. But remember that the script files contain instructions and illustrations, and also that you don't really need a complicated and/or ready-made script to do this: it can be as simple, in your case and assuming you have a selection, as

tell application "Adobe InDesign CS4"
set find text preferences to nothing
set change text preferences to nothing
set find what of find text preferences to "Title One"
set change to of change text preferences to "Title one"
tell selection to change text
set find what of find text preferences to "Title Two"
set change to of change text preferences to "Title two"
tell selection to change text
-- [etc.]
set find text preferences to nothing
set change text preferences to nothing
end tell


Roy

Mindy

unread,
Sep 7, 2011, 7:54:29 PM9/7/11
to indesi...@googlegroups.com
I've always preferred the teach a "min" to fish ... thank you. I'll dig into those scripts and see what I can whip up and how the script might be different for a series of titles rather than one specific title. (I was hoping that the script could work on a selection or a style rather than a specific title).

I'll have a look and appreciate the time you took to respond, Roy. Thanks.

Mindy

> --
> you are subscribed to "InDesign talk" on Google Groups, to post: send email to indesi...@googlegroups.com, to unsubscribe: send email to indesign-tal...@googlegroups.com, for more options visit http://groups.google.com/group/indesign-talk

Roy McCoy

unread,
Sep 7, 2011, 9:36:20 PM9/7/11
to indesi...@googlegroups.com
Mindy wrote:

> I'll dig into those scripts and see what I can whip up and how the script might be different for a series of titles rather than one specific title.

There shouldn't be any essential difference. Note that FindChangeByList is *designed* to work with a list and thus with more than one find/change pattern. You just need to add further lines like

text<tab>{find what:"Title To Be Changed"}<tab>{change to:"Title to be changed"}<tab>{include footnotes:true}<tab>no description

for your multiple titles.

> (I was hoping that the script could work on a selection or a style rather than a specific title).

FindChangeByList does work on a selection, or on the current story or whole document (there's a prompt) if there's no selection when the script is run. It can also work on a style: you just need to add that to findProperties, for example

{find what:"Title To Be Changed", applied paragraph style:"Title"}

You said you had "a series of titles", so I assumed these titles could themselves be used and would likely be unique enough not to need styles in the find properties. I didn't immediately find how to script conversion to sentence case in the InDesign scripting dictionary, because I searched on "sentence" and that didn't yield anything. Checking now on "case", however, I find the changecase command, which could relieve you of the necessity of manually or semi-manually converting the titles for your replace strings. This is a good refresher exercise for me, let's see if I can make my simple script do it in CS 5.5.

tell application "Adobe InDesign CS5.5"


set find text preferences to nothing

set find what of find text preferences to "Title One"

set theFinds to find text selection
repeat with j from (count of theFinds) to 1 by -1
tell text item j of theFinds to changecase using sentencecase
end repeat


set find what of find text preferences to "Title Two"

set theFinds to find text selection
repeat with j from (count of theFinds) to 1 by -1
tell text item j of theFinds to changecase using sentencecase
end repeat


-- [etc.]
set find text preferences to nothing

end tell

I tried this and it works. Shane Stanley taught me a more elegant way of doing this, which in this case would be:

tell application "Adobe InDesign CS5.5"


set find text preferences to nothing
set change text preferences to nothing

set theToBeFounds to {"Title One", "Title Two"}
repeat with i from 1 to count of theToBeFounds
set find what of find text preferences to (item i of theToBeFounds)
set theFinds to find text selection
repeat with j from (count of theFinds) to 1 by -1
tell text item j of theFinds to changecase using sentencecase
end repeat
end repeat


set find text preferences to nothing

end tell

This works too, again assuming you have a selection. Then all you have to do is have your list of titles on separate lines with a return after the last one, GREP change

(.+)\r

to

"$1",[space]

delete the final comma, and paste the result between the curly braces.


Roy


Roy

Mindy

unread,
Sep 7, 2011, 9:52:36 PM9/7/11
to indesi...@googlegroups.com
Oh, Roy. That's SO easy ... heh heh. (here I can't decide if you're giving me too much credit, or not giving yourself enough credit) Thank you. I'll try not to send you off scripting again, but what I am after is altering a series of *unique* titles, no two are the same, that require their case to be altered. So I suspect I would have to do a search by style and do the replace that way.

I'll have to do that after I've put this project to bed or else I'll not get to bed! There aren't a ton to be altered.Thank you for this. Once again, very helpful. I'm going to dedicate my first script to you. (I know that this particular one would be useful on many occasions so worth the effort.)

Mindy

Roy McCoy

unread,
Sep 7, 2011, 10:15:27 PM9/7/11
to indesi...@googlegroups.com
Mindy wrote:

> Oh, Roy. That's SO easy ... heh heh. (here I can't decide if you're giving me too much credit, or not giving yourself enough credit) Thank you. I'll try not to send you off scripting again, but what I am after is altering a series of *unique* titles, no two are the same, that require their case to be altered. So I suspect I would have to do a search by style and do the replace that way.
>

> I'll have to do that after I've put this project to bed or else I'll not get to bed! [...]

I have to get to bed myself, but first... I thought what I sent was good for a series of unique titles, that you have in a list and that could be put in a list for changing or manipulating. Something isn't understood here. Do the titles all have the same style, and does nothing else in the text have that style?


Roy

Mindy

unread,
Sep 7, 2011, 10:23:28 PM9/7/11
to indesi...@googlegroups.com
Ah, you're right. I didn't understand that. The titles do all have the same style and nothing else has that style. I think that I read your "Title 1" to mean a generic title name, but perhaps the "Title one" refers to the first title (no matter the actual title name) in the list. I will look at your email more closely. I don't want you to lose sleep!

Roy McCoy

unread,
Sep 8, 2011, 6:02:51 AM9/8/11
to indesi...@googlegroups.com
Mindy wrote:

> The titles do all have the same style and nothing else has that style.

That simplifies things. You don't need a list at all, then - or an original selection, unless something else has the style elsewhere in the doc. Changing the replacement range from selection to doc (it can be changed back if necessary - see second comment):

tell application "Adobe InDesign CS4"

set find text preferences to nothing

set applied paragraph style of find text preferences to "NAME OF YOUR STYLE HERE"
-- or, if it's a character style, applied character style
set theFinds to find text document 1
-- or, if you need a limited selection, set theFinds to find text selection
repeat with i from 1 to (count of theFinds)
tell text item i of theFinds to changecase using sentencecase
end repeat


set find text preferences to nothing
end tell

The find text preferences need to be reset initially to prevent something from a previous find from interfering with the current one. You say what you want the script to find - here, text with a particular style. You do the find, putting the results into a variable. You use the variable to consecutively change each find to sentence case. You clean up by resetting the find text preferences (here, so that you won't inadvertently search for this style on your next find operation).

I went forward "from 1 to (count of theFinds)" rather than backward "from (count of theFinds) to 1 by -1" as I unnecessarily did before, because the position of the finds in the text is not changed by the changecase operation. If you were changing the finds so that they would afterwards have a different number of characters and their positions would thus be changed, you'd need to go backwards. If you don't see why I can try to explain further.

> I think that I read your "Title 1" to mean a generic title name, but perhaps the "Title one" refers to the first title (no matter the actual title name) in the list.

Sorry if that wasn't clear. I intended it to be understood as "NAME OF YOUR FIRST TITLE HERE", "NAME OF YOUR SECOND TITLE HERE", etc.


Roy

Mindy

unread,
Sep 8, 2011, 10:05:37 AM9/8/11
to indesi...@googlegroups.com
That's great Roy. I *did* interpret your "TITLE 1" at first to be a specific title, so no problem there.
I'm going to look this over an learn from it – I know it will come in very handy.

Thank you!

Mindy

Eweforia

unread,
Sep 8, 2011, 6:40:17 PM9/8/11
to InDesign talk
Say Roy, do you happen to know what options a CS5 user has to do this?
I checked my Scripts folder and there isn't much in it, and certainly
not one called "FindChangeByList." I'd like to learn a little bit
about scripting in CS5 and it would be great if I could following
along with your instructions here.



On Sep 7, 4:49 pm, Roy McCoy <roymccoy...@gmail.com> wrote:
> Yes, there is such a script, but you should adopt the attitude that you can write your own f&c scripts since it really is relatively easy to do so - also because at some point or points you'll very likely have to. The basic script you want came with CS4 in its Scripts folder, I think, and is called "FindChangeByList". There should be a folder with this called   "FindChangeSupport". I don't have my original CS4 scripts and so am not sure about everything, but I suppose you should make a copy of a "FindChangeList.txt" file in that folder, rename the file and take it from there. As the commented content of this file explains, you need to have this file contain a list in the format
> Roy

Michel Raj

unread,
Sep 9, 2011, 2:50:05 AM9/9/11
to indesi...@googlegroups.com
FindChangeByList is in the scripts given with CS5.
I just checked again to be sure.
I have it in the AppleScript folder in the script palette.

Roy McCoy

unread,
Sep 9, 2011, 8:30:30 AM9/9/11
to indesi...@googlegroups.com
Eweforia wrote:

> Say Roy, do you happen to know what options a CS5 user has to do this?
> I checked my Scripts folder and there isn't much in it, and certainly
> not one called "FindChangeByList." I'd like to learn a little bit
> about scripting in CS5 and it would be great if I could following
> along with your instructions here.

If you still haven't found it, you might be looking in the wrong
Scripts folder. I'm not sure what was installed by what or where,
but if you search your disk for "FindChangeByList" with "System files
are included" it may show up. If not, I've put the one I have up at
http://dl.dropbox.com/u/1107821/FindChangeByList.scpt, with a zipped
FindChangeSupport folder (which should be placed in the same folder as
the script) at http://dl.dropbox.com/u/1107821/FindChangeSupport.zip.
You need to copy and/or modify the FindChangeList file in the support
folder for your own purposes.

The more I think about it, however, the more I tend toward Shane
Stanley's way of handling a list of find/change patterns, for instance:

tell application "Adobe InDesign CS5.5"

set find text preferences to nothing
set change text preferences to nothing

set theToBeFounds to {"War", "Lies", "Misery"}
set theToBeChangedTos to {"Peace", "Truth", "Prosperity"}
repeat with i from 1 to count of theToBeFounds
set find what of find text preferences to (item i of theToBeFounds)
set change to of change text preferences to (item i of theToBeChangedTos)
change text document 1
end repeat


set find text preferences to nothing
set change text preferences to nothing
end tell

The lists are easier to prepare doing it this way, I generally don't need
the descriptions, and I can modify the change text line for story or selection
when and if necessary.


Roy

Bret Perry

unread,
Sep 9, 2011, 4:17:17 PM9/9/11
to indesi...@googlegroups.com
Yes, it came with CS5, and unless you moved it, itis in:
/Applications/Adobe InDesign CS5/Scripts/Scripts Panel/Samples/JavaScript
(or Applescript folder if you prefer)

Note: NOT in User scripts folder (in your Home folder which is where you
would put scripts if you were adding them yourself)
/Users/YOUR_USERNAME/Library/Preferences/Adobe InDesign/Version
7.0/en_US/Scripts/Scripts Panel

>--
>you are subscribed to "InDesign talk" on Google Groups, to post: send
>email to indesi...@googlegroups.com, to unsubscribe: send email to
>indesign-tal...@googlegroups.com, for more options visit
>http://groups.google.com/group/indesign-talk
>

Bret Perry
Studio IT Manager/Production Artist
ph 626-463-9365
fax 626-449-2201
bpe...@russreid.com


The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by calling the Help Desk at 866-682-8852.

Please consider the environment before printing this email.

default.jpg

Eweforia

unread,
Sep 9, 2011, 7:55:32 PM9/9/11
to InDesign talk
Brett and Roy, thanks so much. I found it right where Brett said it
would be.


On Sep 9, 2:17 pm, Bret Perry <bpe...@russreid.com> wrote:
> Yes, it came with CS5, and unless you moved it, itis in:
> /Applications/Adobe InDesign CS5/Scripts/Scripts Panel/Samples/JavaScript
> (or Applescript folder if you prefer)
>
> Note: NOT in User scripts folder (in your Home folder which is where you
> would put scripts if you were adding them yourself)
> /Users/YOUR_USERNAME/Library/Preferences/Adobe InDesign/Version
> 7.0/en_US/Scripts/Scripts Panel
>
> On 9/9/11 5:30 AM, "Roy McCoy" <roymccoy...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> >Eweforia wrote:
>
> >> Say Roy, do you happen to know what options a CS5 user has to do this?
> >> I checked my Scripts folder and there isn't much in it, and certainly
> >> not one called "FindChangeByList." I'd like to learn a little bit
> >> about scripting in CS5 and it would be great if I could following
> >> along with your instructions here.
>
> >If you still haven't found it, you might be looking in the wrong
> >Scripts folder. I'm not sure what was installed by what or where,
> >but if you search your disk for "FindChangeByList" with "System files
> >are included" it may show up. If not, I've put the one I have up at
> >http://dl.dropbox.com/u/1107821/FindChangeByList.scpt, with a zipped
> >FindChangeSupport folder (which should be placed in the same folder as
> >the script) athttp://dl.dropbox.com/u/1107821/FindChangeSupport.zip.
>  default.jpg
> 59KViewDownload
Reply all
Reply to author
Forward
0 new messages