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'));
};