Das Skript von Peter Kahrel mach dasselbe (und noch mehr: Kapitälchen, Unterstreichungen, Durchstreichungen) mit einem eleganteren Code:
//CharStyleOfPeterKahrel.js
// attr2style takes two arguments: (1) a string to set the search
// and the attribute value in the style, and (2) a name for the character style.
attr2style( 'fontStyle = "Bold Italic"' , 'Bold Italic' );
attr2style( 'fontStyle = "Bold"' , 'Bold' );
attr2style( 'fontStyle = "Italic"' , 'Italic' );
attr2style( 'position = Position.superscript' , 'SuperScript' );
attr2style( 'position = Position.subscript' , 'SubScript' );
attr2style( 'capitalization = Capitalization.smallCaps' , 'SmallCaps' );
attr2style( 'underline = true' , 'Underline' );
attr2style( 'strikeThru = true' , 'StrikeThru' );
function attr2style( attr, st )
{
app.findPreferences = app.changePreferences = null;
eval( 'app.findPreferences.' + attr );
// comment the following line to look for text with applied character style too (MF)
app.findPreferences.appliedCharacterStyle = app.activeDocument.characterStyles[0];
app.changePreferences.appliedCharacterStyle = checkStyle( attr, st );
app.activeDocument.search( '', false, false, '' );
}
function checkStyle( attr, stylename )
{
if( app.activeDocument.characterStyles.item( stylename ) == null )
{
app.activeDocument.characterStyles.add( { name : stylename } );
eval( 'app.activeDocument.characterStyles.item( stylename ).' + attr );
}
return app.activeDocument.characterStyles.item( stylename );
}