Skip to main content
Participant
September 15, 2009
Answered

Is it possible to do this like?!

  • September 15, 2009
  • 2 replies
  • 2149 views

hello every one ...

i must creat a lot of subtitle (over 100 title) with special properties like special Font , Color , shadow and ...

i can use action to make standar shape for all subs but i need some thing like this :

i able to change properties of one file and automaticly apply to others ,  for example i change the font of the one file and others changed the file

is it possible ?!!!

Unfortunately during the project subs will be changed over and over , if had to open each file and save the changes ...

sorry for bad english . english is my second language ...

This topic has been closed for replies.
Correct answer c.pfaffenbichler

tanx my friend ... nice explanatio ...


how can i set the script in PSD file to get the layer properties form a file ?!!! can i axplain  more ?!!

about the auto refreshing ... you think is not possible ?!

gernetaly what is your solution about my problem ?!! another way diffrent from mine ...


The auto-refreshing is beyond my scope plus I think it may be troublesome in the long run.

You could give the following code a try.

It collects some of the type-features of a selected text-layer (font, size, color, capitalization, leading) and creates a style of the layer-effects, then offers a folder-selection; all psds and tiffs in this folder are then opened and if a text-layer is found those features and the style are applied to them, the files saved and closed.

I haven’t tested how it would handle textItems with more than one font/size/etc. so that might cause problems.

Please test it on a duplicate folder!

// 2009, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

// get document-path and -title;

var myDocument = app.activeDocument;

var myPath = myDocument.path;

var theLayer = myDocument.activeLayer;

if (theLayer.kind == LayerKind.TEXT) {

// collect the elements;

var theFont = theLayer.textItem.font;

var theSize = theLayer.textItem.size;

var theColor = theLayer.textItem.color;

var theCap = theLayer.textItem.capitalization;

var theLeading = theLayer.textItem.leading;

var theStyleName = dateString();

// create style;

// =======================================================

var idMk = charIDToTypeID( "Mk  " );

var desc2 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref1 = new ActionReference();

var idStyl = charIDToTypeID( "Styl" );

ref1.putClass( idStyl );

desc2.putReference( idnull, ref1 );

var idNm = charIDToTypeID( "Nm  " );

desc2.putString( idNm, theStyleName );

var idUsng = charIDToTypeID( "Usng" );

var ref2 = new ActionReference();

var idLyr = charIDToTypeID( "Lyr " );

var idOrdn = charIDToTypeID( "Ordn" );

var idTrgt = charIDToTypeID( "Trgt" );

ref2.putEnumerated( idLyr, idOrdn, idTrgt );

desc2.putReference( idUsng, ref2 );

var idblendOptions = stringIDToTypeID( "blendOptions" );

desc2.putBoolean( idblendOptions, false );

var idLefx = charIDToTypeID( "Lefx" );

desc2.putBoolean( idLefx, true );

executeAction( idMk, desc2, DialogModes.NO );

// select folder;

var theFolder = Folder.selectDialog ("please select folder");

if (theFolder) {

var theFiles = theFolder.getFiles(/\.(tif|psd)$/i);

for (var m = 0; m < theFiles.length; m++) {

var theDoc = app.open(theFiles);

var theTextLayers = collectLayers (theDoc);

for (var n = 0; n < theTextLayers.length; n++) {

// apply the settings;

var theTextLayer = theTextLayers;

theTextLayer.textItem.font = theFont;

theTextLayer.textItem.size = theSize;

theTextLayer.textItem.color = theColor;

theTextLayer.textItem.capitalization = theCap;

theTextLayer.textItem.leading = theStyleName;

// =======================================================

var idASty = charIDToTypeID( "ASty" );

var desc4 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref4 = new ActionReference();

var idStyl = charIDToTypeID( "Styl" );

ref4.putName( idStyl, theStyleName );

desc4.putReference( idnull, ref4 );

var idT = charIDToTypeID( "T   " );

var ref5 = new ActionReference();

var idLyr = charIDToTypeID( "Lyr " );

var idOrdn = charIDToTypeID( "Ordn" );

var idTrgt = charIDToTypeID( "Trgt" );

ref5.putEnumerated( idLyr, idOrdn, idTrgt );

desc4.putReference( idT, ref5 );

executeAction( idASty, desc4, DialogModes.NO );

};

theDoc.close(SaveOptions.SAVECHANGES)

}

};

// delete the style;

var theStyles = StylesGetPresets();

// =======================================================

var idDlt = charIDToTypeID( "Dlt " );

var desc3 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref3 = new ActionReference();

var idStyl = charIDToTypeID( "Styl" );

   ref3.putIndex( idStyl, theStyles.length );

desc3.putReference( idnull, ref3 );

executeAction( idDlt, desc3, DialogModes.NO );

}

else {alert("no textlayer selected")}

}

else {alert("no open document")};

////////////////////////////////////

////// function to get the date //////

function dateString () {

var now = new Date();

var day = now.getDate();

var month = now.getMonth();

month++;

var year = now.getFullYear();

var hour = now.getHours();

var minutes = now.getMinutes();

var seconds = now.getSeconds();

var myDateText = day+"-"+month+"-"+year+"_"+hour+"-"+minutes+"-"+seconds;

return myDateText

};

////// function collect all ltype ayers //////

function collectLayers (theParent) {

if (!allLayers) {

var allLayers = new Array}

else {};

for (var m = theParent.layers.length - 1; m >= 0;m--) {

var theLayer = theParent.layers;

// apply the function to layersets;

if (theLayer.typename == "ArtLayer") {

if (theLayer.kind == LayerKind.TEXT) {

allLayers = allLayers.concat(theLayer)

}

}

else {

allLayers = allLayers.concat(collectLayers(theLayer))

// this line includes the layer groups;

// allLayers = allLayers.concat(theLayer);

}

}

return allLayers

};

////// lifted from xbytor’s styles-1_14.jsx, thanks to him  //////

function StylesGetPresets () {

  var styleKey = charIDToTypeID('StyC');

  var names = [];

  var mgr = StylesGetPresetManager();

  var max = mgr.count;

  for (var i = 0; i < max; i++) {

    var objType = mgr.getObjectType(i);

    if (objType == styleKey) {

      break;

    }

  }

  if (i != max) {

    var preset = mgr.getObjectValue(i);

    var list = preset.getList(charIDToTypeID('Nm  '));

    var max = list.count;

    for (var i = 0; i < max; i++) {

      var str = list.getString(i);

      names.push(str);

    }

  }

  return names;

};

function StylesGetPresetManager () {

  var classApplication = charIDToTypeID('capp');

  var typeOrdinal      = charIDToTypeID('Ordn');

  var enumTarget       = charIDToTypeID('Trgt');

  var ref = new ActionReference();

  ref.putEnumerated(classApplication, typeOrdinal, enumTarget);

  var appDesc = app.executeActionGet(ref);

  return appDesc.getList(stringIDToTypeID('presetManager'));

};

2 replies

c.pfaffenbichler
Community Expert
Community Expert
September 16, 2009

Should all text-layers in all the documents use the same font etc. in the end?

Which properties are likely to be changed, stuff like spacing and scale, too, or just size, font and color?

matin-naAuthor
Participant
September 16, 2009

i must put the same font to all texts ... becaus all PSD's are same ...

Font , Font Size , Color , and layer effects is Important ... others can made by this ones ...

I need some think like template in programing ....

some codes use template . if you change the template properties directly, others codes (that use it) took effect automaticly ...

or better example ... if you use  some file like PSD's in Premiere or After Effect , when you save the new changes in the PSD , other Program that use this file , apply new setting automaticly ...

Participant
September 16, 2009

I have read a lot of htese forumtexts. But I must be honest. As much as I have read so many texts i am very unsure. I pretty sure that I have no clue about adobe. Can someone recomand a good book?

MyBrands

Inspiring
September 15, 2009

Seems like this would be a good use for the After Effect XML support.