Scripting inDesign: Loop through the layers
I'm doing a script that will:
To loop through all the layers in a document.
Add the layers unlocked in table
Loop in this table and glue them in place on each layer.
I don't know how to loop through all the layers.
Here is my script (I used? to represent where would the loop through all the part of layers):
JavaScript document
Set up a table to keep unlocked layers
var layercollection = [];
Browse layers and unlocked the layercollection table
for (i = 0;? i ++) {}
app.activeDocument.activeLayer = app.activeDocument.layers.itemByName (?);
If (app.documents [0] .layers.) ([i]). Locked) == false;
layercollection.push (Layers.itemByName ([i]))
}
Loop in table layercollection and paste in place
for (i = 0; i < layercollection.length; i ++) {}
app.activeDocument.activeLayer = app.activeDocument.layers.itemByName (tl [i]);
app.pasteInPlace (); Dough
}
Can someone help me complete my script.
Thank you!
Did you test them all your solutions in a real world scenario?
Theoretically, it should work this way (if one ignores that a layer is invisible, too), but even without the problem of invisible layers app.pasteInPlace () prefer to paste into the original layer, if the option "Paste remembers Layers" is checked.
So I recommend you do the following:
var oldPasteRem = app.clipboardPreferences.pasteRemembersLayers; //uncheck "Paste Remembers Layers" app.clipboardPreferences.pasteRemembersLayers = false; for (i = 0; i < app.activeDocument.layers.length; i++) { //Maybe the user does not want objects pasted to invisible layers: if(app.activeDocument.layers[i].visible == true && app.activeDocument.layers[i].locked == false) { app.activeDocument.activeLayer = app.activeDocument.layers[i]; app.pasteInPlace(); }; }; //Restore the old condition: app.clipboardPreferences.pasteRemembersLayers = oldPasteRem;
Uwe
Tags: InDesign
Similar Questions
-
loop through the layers defining the lock and visibility
I need to loop through the layers in the active document and the value of the properties of the layer is false or true. I tried to create a loop using a method 'for', but it doesn't seem to work. I have renounced the method 'for' because I kept running into a problem. I have set all layers with these settings just the odd ones (2,4,6, etc.). Here is sample if it was written.
myLayer = myDoc.layers var [2];
myLayer.visible = false;
myLayer.locked = true;
myLayer = myDoc.layers var [4];
myLayer.visible = false;
myLayer.locked = true;
myLayer = myDoc.layers var [6];
myLayer.visible = false;
myLayer.locked = true;
myLayer = myDoc.layers var [8];
myLayer.visible = false;
myLayer.locked = true;
I have 208 layers, so doing it this way would be way to long. Any help would be appreciated.
Illustrator CC 2014 running.
After I wrote this and tested, I saw that Carlos had already answered, but I thought that I would post it anyway. Carlos KNOWS how much I love JS... ;-)
One difference is that, since it was not clear to me which layer you talk like layer #1, I started at the bottom of the scale. I hope this helps. -TT
var aDoc = app.activeDocument; var lc = aDoc.layers.length; for (var i = 2; i <= lc; i+=2) { var curLayer = lc - i aDoc.layers[curLayer].visible = false; aDoc.layers[curLayer].locked = true; }
-
How to loop through the layers of the children of a group with jsx?
Need to change the name of a child layers in a group? How to get there?
Kind regards
Dorothy
What is giving you problems?
Perhaps this example can help:
#target photoshop var theLayers = collectLayers(app.activeDocument.activeLayer, []); alert (theLayers.join("\n")); ////// function collect all layers ////// function collectLayers (theParent, allLayers) { if (!allLayers) {var allLayers = new Array} else {}; var theNumber = theParent.layers.length - 1; for (var m = theNumber; m >= 0;m--) { var theLayer = theParent.layers[m]; theLayer.name = theParent.name + "_" + m; // apply the function to layersets; if (theLayer.typename == "ArtLayer") { allLayers.push(theLayer) } else { allLayers = (collectLayers(theLayer, allLayers)) // this line includes the layer groups; allLayers.push(theLayer); } }; return allLayers };
-
I have the data into two table with the structure of similar column, I want to loop through the data in these two tables
based on some condition and runtime that I want to put the query in loop for example, the example is given, please help me
create table ab (a number, b varchar2 (20));
Insert into ab
Select rownum, rownum. "" sample "
of the double
connect by level < = 10
create table bc (a number, b varchar2 (20));
Insert into BC.
Select rownum + 1, rownum + 1 | "" sample "
of the double
connect by level < = 10
declare
l_statement varchar2 (2000);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: =' select * ab ';
on the other
l_statement: =' select * from bc';
end if
I'm in execute immediate l_statement - something like that, but I don't know
loop
dbms_output.put_line (i.a);
end loop;
end;
Something like that, but this isn't a peace of the code work.
Try this and adapt according to your needs:
declare
l_statement varchar2 (2000);
c SYS_REFCURSOR;
l_a number;
l_b varchar2 (20);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: = "select a, b, AB;
on the other
l_statement: = "select a, b from bc;
end if;
--
Open c for l_statement;
--
loop
extract the c in l_a, l_b;
When the output c % notfound;
dbms_output.put_line (l_a |') -' || l_b);
end loop;
close c;
end;
/
-
Loop through the list in flex 4 conclusion d buttons
Anyone know how to completely recursively loops through the list in flex 4 by pulling the bodies of buttons. This way I can apply my effects for buttons on the screen at the same time?
You just create a subclass of button that has the desired effect and use it throughout your application.
Gordon Smith
Adobe Flex SDK team
-
loop through the list in flex 4
I want to loop through the list and apply the following code to each button, the checkbox and the descent down in my application
mouseOver = "animateHover ('theComponentID').
How is that possible?
Hello
This should do what you want, you must add the eventlistener now your animated can be run from the th event handler.
protected function button1_clickHandler(event:MouseEvent):void
{
for (var i: Number = 0; i<>
{
var obj:Object = this.getElementAt (i);
If (flash.utils.getQualifiedClassName (obj) is 'spark.components::Button')
{
(obj as Button) .addEventListener (MouseEvent.MOUSE_OVER, onMouseOver);
}
If (flash.utils.getQualifiedClassName (obj) is 'spark.components::CheckBox')
{
(obj as CheckBox) .addEventListener (MouseEvent.MOUSE_OVER, onMouseOver);
}
}
}
private void onMouseOver(event:MouseEvent):void
{
animateHover (event.currentTarget);
}
-
Loop through the objects - test links
Hello
I have a script that moves all instances of an object linked according to the defined user X, the values of Y.
To do this, I need to loop through all the objects with links
What is the best way to do it?
From now on, that's what I do:
var g = myDoc.allGraphics; for (var i=0; i<g.length; i++) { if (g[i].itemLink.name == USER_LINK) { g[i].parent.move(undefined, [USER_X, USER_Y]); } }
It works well, however, I ran into a few problems where the link is null
Also, is it always the graph linked, or its parent may be related as well?
If not, then I can just condition that if itemLink == null - continue
Advice and guidance would be much appreciated
Thank you
David
It works well, however, I ran into a few problems where the link is null
if (g[i].itemLink && g[i].itemLink.name == "USER_LINK") // should be enough
Also, is it always the graph linked, or its parent may be related as well?
Graphics can be linked to the ==> itemLink ! = null and itemLink.status may vary
or stuck ==> itemLink == null.
As much as I know the graphic.parent may not be related.
However not all are related graphic.parent can be moved. I e. those who are anchored with
AnchorPosition.INLINE_POSITION and AnchorPosition.ABOVE_LINE
Above the case can be a source of error as well.
Also consider locked object or the layers locked together.
Jarek
-
A loop in the layers is slow.
Hi, so I'm doing a script that will go through all the layers of an off-line, sets the size of the layer to a width and height and export it to a separate file. I finished the script but it really really slow. I read that to access the layers of the model DOM is slow and I should use the ActionManager instead, but I can't find any documentation on the use of the ActionManager.
That's what I have so far:
OK, so now I create a document with the size I want. Copy the layer I want the current doc to the new and save the document. When I see a group I create a folder on the directory and calling the function recursively.
var refDoc; var tempDoc; function main(){ refDoc = app.activeDocument; tempDoc = app.documents.add(500, 500, 72, "tempDoc", NewDocumentMode.RGB, DocumentFill.TRANSPARENT); app.activeDocument = refDoc; mainFolder = app.activeDocument.path + "/test"; savetAllLayers(app.activeDocument, mainFolder); tempDoc.close (SaveOptions.DONOTSAVECHANGES); } function saveAllLayers(group, folderName){ var groupFolder = new Folder(folderName) for (var i = 0; i < group.layers.length; i++){ if (group.layers[i].typename.valueOf() === "LayerSet"){ var groupFolder = new Folder(folderName + "/" + group.layers[i].name); if (!groupFolder.exist){ groupFolder.create(); } saveAllLayers(group.layers[i], groupFolder); } else if (group.layers[i].typename.valueOf() === "ArtLayer"){ try { app.activeDocument = refDoc; group.layers[i].copy(); app.activeDocument = tempDoc; var targetLayer = tempDoc.artLayers.add(); tempDoc.paste(); tempDoc.activeLayer.resize(500, 500); var options = new ExportOptionsSaveForWeb(); options.fomat = SaveDocumentType.PNG; options.PNG8 = false; options.transparency = true; options.optimized = true; //Export Save for Web in the current folder tempDoc.exportDocument(File(folderName +'/' + group.layers[i].name +'.png'), ExportType.SAVEFORWEB, options); targetLayer.remove(); } catch (e){ alert("Error on layer: " + group.layers[i].name + "\n\n\n" + e.message); } } } return }}
How can I use the ActionManager to achieve? Thank you.
I don't think that AM will help much, time to eat the operation is resizing and you can't do anything with AM to make it faster.
the only thing where the AM could help is passing by layers, than anything that I don't see how you can do it faster...
Here is a code with AM that will do what your function, I compared the time for each of them and there is a small improvement with AM in terms of time but it's not that much notable.
function {BCM_saveAsFolders (path)
refDoc1 = app.activeDocument;
var size = {w: 500, h:500};
var tempDoc1 = app.documents.add (500 500, 72, "BCM_rrrre_tempDoc1", NewDocumentMode.RGB, DocumentFill.TRANSPARENT);
app.activeDocument = refDoc1;
Var ref = new ActionReference();
ref.putEnumerated (charIDToTypeID ('Lyr'), charIDToTypeID ('Ordn'), charIDToTypeID ('Trgt'));
var aa = 0;
try {App.activeDocument.backgroundLayer} catch (Err) {aa = 1};
var count = executeActionGet (Ref), .getInteger (charIDToTypeID ('Cnt')) - aa; / / the number of layers in the document
var x, y, r = 0;
var currentFolder = new Folder (pathname);
if(!currentFolder.Exists) {currentFolder.Create ()};
for (i = count; I > = 0; i--) {/ / the recursive loop}
REF = new ActionReference();
ref.putIndex (charIDToTypeID ("Lyr"), I);
try {}
var / / desc = executeActionGet (ref);
} catch (err) {break ;}
var NomCouche = desc.getString (charIDToTypeID ('n'));
var Id = desc.getInteger (stringIDToTypeID ('layerID'));
ls var = desc.getEnumerationValue (stringIDToTypeID ("layerSection"));
LS = typeIDToStringID (ls);
var vis = desc.getInteger (stringIDToTypeID ("visible")); r
If (ls == 'layerSectionContent') {}
duplicateTotempDoc1umentAndSaveByIDX (i, (currentFolder.fullName + "/" + NomCouche), sizes, tempDoc1);
app.activeDocument = refDoc1;
}
If (ls == 'layerSectionStart') {/ / If this is the beginning of a series of layer}
currentFolder = new file (currentFolder.fullName + "/" + NomCouche);
If (! currentFolder.exists) {}
currentFolder.create ();
}
}
If (ls == 'layerSectionEnd') {/ / if it's the end of a layerSet}
var cPthStr = currentFolder.fullName.toString ();
currentFolder = new Folder(cPthStr.substring(0,cPthStr.lastIndexOf("/"))); "
}
}
tempDoc1.close (SaveOptions.DONOTSAVECHANGES);
}
function duplicateTotempDoc1umentAndSaveByIDX (idx, path, size, tempDoc1) {}
= double layer in a new document
var idDplc = charIDToTypeID ("Dplc");
var desc57 = new ActionDescriptor();
var idnull = charIDToTypeID ("null");
var ref47 = new ActionReference();
ref47.putIndex (charIDToTypeID ("Lyr"), idx);
desc57.putReference (idnull, ref47);
idT var = charIDToTypeID ("T");
var ref48 = new ActionReference();
var idDcmn = charIDToTypeID ("Dcmn");
ref48.putName (idDcmn, "BCM_rrrre_tempDoc1");
desc57.putReference (idT, ref48);
var idVrsn = charIDToTypeID ("VR");
desc57.putInteger (idVrsn, 5);
executeAction (idDplc, desc57, DialogModes.NO);
app.activeDocument = tempDoc1;
tempDoc1.activeLayer.resize (500, 500);
var options = new ExportOptionsSaveForWeb();
options.format = SaveDocumentType.PNG;
Options. PNG8 = false;
options. Transparency = true;
options. Optimized = true;
Save for Web in the folder being exported
tempDoc1.exportDocument (new file (path + ".png"), ExportType.SAVEFORWEB, options);
tempDoc1.activeLayer.remove ();
}
startTime var = new Date () .getTime ();
BCM_saveAsFolders (Folder.desktop + "/ test");
endTime var = new Date () .getTime ();
alert (endTime - startTime);
-
Hello
I'm trying to get just the property groups that are visible to a layer in my script. Is there such a property?
For example, when I loop through groups of properties of a shape layer, I get masks, layer, surface Options and Audio property groups Styles, when none of these are appropriate. I tried to use the (.elided) property, but it gives me just the 'Content' hidden folders within the groups of vector and 'Masks' in 'membership Options '.
* on a side note, I got the error "not"adjustable expression"with this property, because the property is a property of the parent is hidden." When you try to access X or Y Rotation on one layer 2D. It makes it seem like there is somewhere a Boolean value 'hidden' in the property object, but I can't.
Hello
'elided' and 'hidden' both have purpose UI (make the lighter user interface) but are very different:
- 'j' is a static property groups attribute (readonly, and After Effects never becomes the value internally).
The children of an elided group are not necessarily élidés.
- 'hidden' is NOT an attribute, is dynamic and "undocumented".
The UI of effects after mask everything that is not necessary in the layer property tree (for example the Group of hardware options is hidden when the layer is not 3D, because it is not used anyway).
Properties and masked groups are always there and is accessible by script, you can read their values and attributes, Scout their subtree of property, but we cannot define anything on them or select them (in both cases, that an error is generated).
And the children of a hidden group are hidden.
Since there is no corresponding to 'hidden' attribute, it is uncomfortable to know whether or not a property is hidden. I only see one case of 'treatment '.
For example:
myLayer.layerStyle is hidden? <===>! myLayer.layerStyle.canSetEnabled
myLayer.transform.xRotation is hidden? <===>! myLayer.transform.xRotation.canSetExpression
myLayer.mask is hidden? <===>myLayer.mask.numProperties = 0
myShapeLayer.content is hidden? <===>fake (never hidden, even if it is empty)
etc...
Xavier.
===>===>===>===> -
Recursive loop through the file system.
Hello!
I'm trying to figure if Javascript is my answer to my problem. I have been able to re - write all my AppleScript scripts that manipulate Illustrator with the exception of those that he had to use the file system. We stayed in PC at work and now I have to figure this out. Our art files are saved with a number of 7 digits, followed by the name of art in the file. Ex: 1000049-Bob Garage. My applescript had a recursive loop that worked its way down through the structure of the files on our server art until it finds the record low where it belonged, then saved in itself. Here is an example of how the structure of server files (these are the folder names) is extended:
1000000-1004999
1005000-1005999
1010000-1014999
and so on.
The script would load all foldernames in the first level of the directory, loop through them and watch the first and last name of each of these folder names, then compare the Illustrator file name to them. If my file is between the two, then the loop itself, called loaded the files inside of that folder and in doing so, working its way down through the folders through the tree structure until there where records is no longer. At this point, the file was saved, in the order, where it should be.
I have no idea on how to start this task with Javascript, if this is possible even with a language developed for browsers. I'm with other people who are frustrated by such a widely adopted language, if little info is available on its use outside the browser. If anyone can tell me all resources dealing with Javascript programming of the file system, or even to have the kindness to write this little monster for me, I'd always in your debt!
Thanks in advance for any time you spend with this problem!
Open the ESTK, and then on the Help menu, you will find a link to the Javascript Tools Guide. You will find everything that you need in Chapter 3 file system access.
-
In a table - looping through the rows and the stored procedure call
APEX version: 3.2.0.00.27
Hello
I searched the forum and tried a few things but could not make it work.
I have a tabular presentation, developed with the help of the ATD ( )
What I'm trying to do now:
-After submit and validations, loop through all the lines and
-call a stored procedure passing 3 parameters obtained from each of the lines on the form of tables. This procedure will be an update of a database table.
On the forum, I found that I could do the loop "* FOR i IN 1..." APEX_APPLICATION.g_f03. "LOOP COUNT *" syntax.
Only for testing purposes, I tried just to view information with the following (On Load - after a footer) process (example of Denes Kubicek == > http://deneskubicek.blogspot.com/2009/05/execute-javascript-throuhg-plsql.html):
The foregoing would give me a ' * ORA-01403: no data found * ' message. I tried through various variants of APEX_APPLICATION.g_f0* #*, but still can't get anything to display correctly. In commenting on all the lines referring to APEX_APPLICATION.g_f0x above, the date would be are they displayed fine.declare v_today varchar2 (200); begin -- :P40_test := APEX_APPLICATION.g_f03(1); -- :P40_test2 := APEX_APPLICATION.g_f04.COUNT; :P40_test2 := 100; v_today := to_char (sysdate, 'dd.mm.yyyy'); --FOR i IN 1.. APEX_APPLICATION.g_f03.COUNT LOOP :P40_test := APEX_APPLICATION.g_f02(2); HTP.p ('<script type="text/javascript">'); HTP.p ( 'alert(''Today is ' || v_today -- || APEX_APPLICATION.g_f04(APEX_APPLICATION.g_f03(i)) || '.\n' || 'end!'');' ); HTP.p ('</script>'); -- :P40_test := APEX_APPLICATION.g_f02(APEX_APPLICATION.g_f02(i)); --END LOOP; end;
I tried uncomment the FOR... LOOP and play with the code (defining the process runs "On submit - after calculations" and Validations), I got was a ' * ORA-06502: PL/SQL: digital error or value: character conversion number error * "message.
Here is the script of the form in a table:
Regarding the parameters for the stored procedure, it would the MSLINK, VALVE_NUMBER and the VALVES_STYLE. FEATURE.select "V"."MSLINK", -- hidden (number) "V"."INSTALLATION_DATE", -- editable date picker "V"."MANUFACTURER_INDICATOR", -- editable (cascading LOV -- text) "V"."MODEL_INDICATOR", -- editable (cascading LOV -- text) "V"."DIAMETER_INDICATOR", -- editable (LOV -- number) "V"."PURPOSE_INDICATOR", -- editable (LOV -- text) "V"."VALVE_NUMBER", -- shown but not editable -- number "V"."MODIFY_DATE", -- shown but not editable "V"."MODIFY_USER", -- shown but not editable "V"."VALVES_STYLE"."FEATURE" -- shown but not editable -- number from "#OWNER#"."VALVES" "V" Where "V"."PROJECT_ID" = :P1_PROJECT_NUMBER AND "V"."VALVES_DFLAG" = 0
Help, please!
(Sorry for the long post).
Thank you
TanHi, Tan,
I have not seen that type of object - I've only used custom types for purposes of test years ago and have never used their within Apex!
One possibility is that the value of checksum being is based on all of the content of these fields, rather than only the part of the FEATURE. If there are other parts of the object, you could include those items as well.
Otherwise, as you f01 KP for a record, you will need to retrieve the values of the FUNCTION in your PL/SQL code directly from the table (because the user cannot modify these fields, you can be sure that the values in the table will be still valid).
Andy
-
help to loop through the elements of page
Hello
I am new to InDesign scripting and I need a way to programmatically iterate through the items on a page in a document and get the entire block of text ID (Using javascript). Once I have a match of the text block I'm looking for, I'll have to update its content. Is there an easy way to do this?
Thanks in advance!
-Lloyd
Hey!
var myTextFrames = app.activeDocument.textFrames; var myTextFramesNo = myTextFrames.length;
Now myTextFramesNo has number of blocks of text in the document and myTextFrames holds text objects frame. Now you can run through the blocks of text and content of the kit for each of them like this:
myTextFrames[0].contents = "My Frame Contents";
This is for beginning
--
tomaxxi
-
Photoshop script to copy all the layers of close PSD to open the current document
Hi, I have very limited capacity script so this task is above my pay grade
I'm looking for a script to read and copy all the layers in a PSD saved file and copy them into the current active document. The two documents have the same size and I need to be able to change text layers after copying. Anyone has any advice or examples of how I might be able to do this?
Thank you in advance for any help you can offer.
Kind regards
Marcus
Try the script in entry below. You must open the destination file, and you must put in the path and name where your source file. It will not choose a layer from background from the source file.
#target photoshop var sFile = new File('~/desktop/template.psd');//change path to template file var doc = activeDocument; var sDoc = open(sFile); var idselectAllLayers = stringIDToTypeID( "selectAllLayers" ); var desc2 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref1 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref1.putEnumerated( idLyr, idOrdn, idTrgt ); desc2.putReference( idnull, ref1 ); executeAction( idselectAllLayers, desc2, DialogModes.NO ); var idDplc = charIDToTypeID( "Dplc" ); var desc5 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref2 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref2.putEnumerated( idLyr, idOrdn, idTrgt ); desc5.putReference( idnull, ref2 ); var idT = charIDToTypeID( "T " ); var ref3 = new ActionReference(); var idDcmn = charIDToTypeID( "Dcmn" ); ref3.putName( idDcmn, doc.name ); desc5.putReference( idT, ref3 ); var idVrsn = charIDToTypeID( "Vrsn" ); desc5.putInteger( idVrsn, 5 ); var idIdnt = charIDToTypeID( "Idnt" ); var list1 = new ActionList(); list1.putInteger( 3 ); list1.putInteger( 4 ); desc5.putList( idIdnt, list1 ); executeAction( idDplc, desc5, DialogModes.NO );
-
Looping through the operator stored in the table
I have a table test
oprtr op_val > =. 100 = 50 < =. 10 < 5 create table test (oprtr varchar2 (5), op_val number);
Insert test values (' > =', 100);
Insert into test values ('=', 50);
insert into test values ("< =', 10");
Insert test values (' < ', 5);
I tried to loop through all the conditions of this table, this table is configurable, and there are cases where the new terms will be added and the old conditions can be modified or deleted,
I wanted to do something like that, is there a way to do it or I have to write manually if condition to test all these cases by taking all the considerartion operator.
Val: = 500;
I'm in (select * from test)
loop
If val i.oprtr i.op_val then
dbms_output.put_line ('True Condition is' |: o PRTR);
end if;
end loop;
Please help me if there is a way to do it.
Hello raj4tech
Here's an example how you can solve this problem:
DECLARE
Val the NUMBER: = 500;
v_statement VARCHAR2 (500);
v_result VARCHAR2 (10);
BEGIN
FOR I IN (SELECT oprtr, op_val
OF THE TEST
)
LOOP
BEGIN
v_statement: = 'SELECT BOX WHEN "| To_char (Val). ' ' || i.oprtr | ' ' || To_char (i.op_val) | "THEN" TRUE"OTHER"FALSE"END AS A RESULT OF THE DOUBLE."
V_statement EXECUTE IMMEDIATE
IN v_result;
DBMS_OUTPUT. PUT_LINE (' "' |") To_char (Val). ' ' || i.oprtr | ' ' || To_char (i.op_val) | ""--> Result: ' | v_result);
END;
END LOOP;
END;
/
"500 > = 100 '--> result: TRUE
'500 = 50'--> result: FALSE
' 500 <= 10" ="" --="">result: FALSE ".
' 500 < 5" ="" --=""> result: FALSE ".
=>I hope it helps.
Best regards, David
-
Hello
I have the following code. It modifies the metadata of a file and it works according to the needs, regardless the fact that you must be in the image folder to change the metadata of these images. What should I change in order for me to simply open the parent directory and for the script to go through all the child pages one by one, running the script?
#target bridge if( BridgeTalk.appName == "bridge" ) { var vfRename = new MenuElement( "command", "VF Rename", "at the end of Tools" , "vfRename01" ); } vfRename.onSelect = function () { app.document.deselectAll(); var thumbs = app.document.getSelection("jpg"); for(var a in thumbs){ var f =thumbs[a].spec; var parts = decodeURI(f.name).replace(/- \d+.jpg$/i,'').split('&&&'); setMetadata( File(f), parts ) } function setMetadata( file, parts ){ var Title = parts[0].toString() + " at " + parts[1].toString() + " by " + parts[2].toString(); var Desc = parts[0].toString() + " at " + parts[1].toString() + " by " + parts[2].toString(); var Author = parts[2].toString(); if ( !ExternalObject.AdobeXMPScript ) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'); var xmpf = new XMPFile( File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE ); var xmp = xmpf.getXMP(); xmp.deleteProperty(XMPConst.NS_DC, "title"); xmp.appendArrayItem(XMPConst.NS_DC, "title", Title, 0, XMPConst.ALIAS_TO_ALT_TEXT); xmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default"); xmp.deleteProperty(XMPConst.NS_DC, "description"); xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc ); xmp.deleteProperty(XMPConst.NS_DC, "creator"); xmp.appendArrayItem(XMPConst.NS_DC, "creator", Author, 0, XMPConst.ARRAY_IS_ORDERED); for(var s in parts){ xmp.appendArrayItem(XMPConst.NS_DC, "subject", parts[s], 0,XMPConst.PROP_IS_ARRAY); } if (xmpf.canPutXMP( xmp )) { xmpf.putXMP( xmp ); } xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY ); } }
If (BridgeTalk.appName == 'bridge') {}
var vfRename = new MenuElement ('order', "Rename VF", "at the end of the tools', 'vfRename01');
}
vfRename.onSelect = function () {}
records of var = [];
topLevel var = Folder (app.document.presentationPath);
records = FindAllFolders (topLevel, records);
Folders.unshift (topLevel);
{(f var in folders)
Alert (Folders [f]);
var inches is folders [f] .getFiles ("*.jpg");.
for (var a helping hand in) {}
var f = [a] inches;
var parts = decodeURI (f.name).replace(/-\d+.jpg$/i, ") .split ('& &');)
setMetadata (file (f), parties)
}
};
setMetadata (file,) {} function
var title = parts [0] m:System.NET.SocketAddress.ToString () + "" + parts [1] m:System.NET.SocketAddress.ToString () + 'by' + parts [2] m:System.NET.SocketAddress.ToString ();
var / / Desc = parts [0] m:System.NET.SocketAddress.ToString () + "" + parts [1] m:System.NET.SocketAddress.ToString () + 'by' + parts [2] m:System.NET.SocketAddress.ToString ();
var author = parts [0] m:System.NET.SocketAddress.ToString () + "|" + parts [1] m:System.NET.SocketAddress.ToString ();
Headline = parts [1] var m:System.NET.SocketAddress.ToString ();
If (!.) ExternalObject.AdobeXMPScript) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
var xmpf = new XMPFile (File (file) .fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
XMP var = xmpf.getXMP ();
xmp.deleteProperty (XMPConst.NS_DC, "title");
xmp.appendArrayItem (XMPConst.NS_DC, "title", title, 0, XMPConst.ALIAS_TO_ALT_TEXT);
xmp.setQualifier (XMPConst.NS_DC "title [1]", "http://www.w3.org/XML/1998/namespace", "lang", "x - default");
xmp.deleteProperty (XMPConst.NS_DC, "description");
xmp.setLocalizedText (XMPConst.NS_DC, "description", null, "x-default", Desc);
xmp.deleteProperty (XMPConst.NS_DC, 'creator');
xmp.appendArrayItem (XMPConst.NS_DC, 'creator', author, 0, XMPConst.ARRAY_IS_ORDERED);
for {(var s in parts)
xmp.appendArrayItem (XMPConst.NS_DC, "subject", parts [s], 0, XMPConst.PROP_IS_ARRAY);
}
If (xmpf.canPutXMP (xmp)) {}
xmpf.putXMP (xmp);
}
xmpf.closeFile (XMPConst.CLOSE_UPDATE_SAFELY);
};
function FindAllFolders (srcFolderStr, destArray) {}
var fileFolderArray =. getFiles() folder (srcFolderStr);
for (var i = 0; i)< filefolderarray.length;="" i++="" )="">
var fileFoldObj = fileFolderArray [i];
If (fileFoldObj instanceof File) {}
} else {}
destArray.push (Folder (fileFoldObj));
FindAllFolders (fileFoldObj.toString (), destArray);
}
}
Return destArray;
};
};
Maybe you are looking for
-
Hello. I have a table of cluster and its 20 elements inside. I want in a tab (page 1, page 2) show 10 first elements in page 1 and last 10 items in page-2 on the front panel. How can I do that. My dashboard cluster is attached. Thank you.
-
Vista - installing KB2237744 getting error code: 80070652
When I tried to install the update KB2237744, MS Search Enhancement Pack, there no 80070652 returned error code. I see no solution to this particular error code. I am running Windows Vista.
-
Clock is incorrect when booting.
I work in an office of the State agency where all computers are registered in the field of our agency. For the last 2 months, we have noticed a problem with our clocks on our computers running Rapids 3 minutes when they are started in the morning. Ab
-
OfficeJet pro 8500: is my officejet pro 8500 store all scanned or copied information
My Officejet pro 8500 dead. Are there personal information stored in the printer I need to erase or destroy before recycling the machine?
-
BlackBerry Blackberry Passport engulfed my data while I was asleep
My BB Passport engulfed my data while I was asleep and I don't know if it was my camera or my carrier. I called my provider and they said: "Yes your data have been used 3-5 a.m." but they don't tell me how. They suggested that I look at my 'event log