23 Replies Latest reply on Aug 23, 2018 12:59 PM by naeema79951470

    Action script does not working

    andrejt72626160

      Hello.

      i made new action: It goes like this: set file info to current document (i set the file info and copyright info and save it in adobe\xmp\metadata templates before). So the action add meta data from xmp file (i choose keep original data, but append matching properties from template) and save it. Action works fine, but when i wanna do it automatic in script events manager i got nothing. I set action setting when a new document is made or when i save a document or open, but nothing works. If i save a document in jpg it has no updated copyright data.

       

      any advice?

        • 1. Re: Action script does not working
          JJMack Most Valuable Participant

          andrejt72626160  wrote

           

          Hello.

          So the action add meta data from xmp file (i choose keep original data, but append matching properties from template) and save it. Action works fine

          How do you do that logic in an action? Can you post the Action and template.  Upload them to a file sharing site and post a link to them.  I would think if you want to update metadata information that is not present you would need to script that to process the metadata that is there so you know what metadata needs to be added or updated.   That something like that could not be done in a straight action that some scripting would be needed.  I have only used metadata templates in the Bridge  to batch add metadata to image collections.  When I use metadata information in Photoshop I have always used Photoshop scripting in actions or a straight script.  The Script Event Manager can trigger scripts as well ad action as event handlers.

          • 2. Re: Action script does not working
            andrejt72626160 Level 1

            I did it exactly like in this video.

             

            • 3. Re: Action script does not working
              JJMack Most Valuable Participant

              I know File Info cam import metada from templates and see ther notes soe it look like what yot say your do is posible.

               

              Specify how you want to import the data:

              Clear Existing Properties And Replace With Template Properties

              Replaces all metadata in the file with the metadata in the XMP file.

              Keep Original Metadata, But Replace Matching Properties From Template

              Replaces only metadata that has different properties in the template.

              Keep Original Metadata, But Append Matching Properties From Template

              (Default) Applies the template metadata only where no metadata value or property currently exists in the file.

              • 4. Re: Action script does not working
                JJMack Most Valuable Participant

                Can you show a screen capture of your script event managers event handlers set up events.  I only add garbage to file info field if it not there the even manager runs my script on open document and new document events. I have not a problem. Each version of Photoshop has it own event manager. You need to set each version up.  I only use these events in CC 2015.5 and CC 2017 to get around Adob's new bug in scripting.

                 

                Is every image you edit your to place your copyright on????

                Capture.jpg

                • 6. Re: Action script does not working
                  andrejt72626160 Level 1

                  Now if I open a document i dont have copyright sign on it, when export pictire i get copyright sign on it but in file I exported i dont have info.

                  Untitled-1.jpg

                   

                  Capture.JPG

                  • 7. Re: Action script does not working
                    JJMack Most Valuable Participant

                    You should not need the export and save events and if you use export Save for web by default that will strip metadata. you need to make sure you use save for web options to preserve metadata like copyright info.

                    • 8. Re: Action script does not working
                      andrejt72626160 Level 1

                      Sorry but i realy dont get it. Even if i save it via save as, my image does not have copyright info in it, but in PS i have a sign, so if i save it again the copyright info is baked in.

                      • 9. Re: Action script does not working
                        JJMack Most Valuable Participant

                        All I can tell you is I do not have your problem on my windows 10 system with PS CC 2017.  I do not think you want the sanad data in all your file thar seems to be set in your template.  I set up a template on my machine created an action to apply it ans setup the script enevt manager ro run is one new documenf ant open docyment.  I do not test open document nut new document doe get copyrigher. as you can see here.

                        Capture.jpg 

                        • 10. Re: Action script does not working
                          andrejt72626160 Level 1

                          Thank you for your help. If I open a document my script worked fine if i make new document or if i save picture, my script doesnt work. Mystery.

                          • 11. Re: Action script does not working
                            JJMack Most Valuable Participant

                            You should not need the save event how could a document be save that was not first open or made from a new dicument.   The only thing I tested was creating new document the action was alway triggered and added the copyright. 

                             

                            Why is Open events working for you where new document events are not.  If what you state is actually happening you should be able to open a files you saved without your copright and your copyright should be added by the open document event.  Can you do that? 

                            • 12. Re: Action script does not working
                              naeema79951470 Level 1

                              Hi JJMack so sorry to ask here, I dont know how to go about creating my own thread, my script does not want to work, what am i doing wrong

                                function step5(enabled, withDialog) {

                                  if (enabled != undefined && !enabled)

                                    return;

                                  var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                  var desc1 = new ActionDescriptor();

                                  var ref1 = new ActionReference();

                                  ref1.putProperty(cTID('Prpr'), cTID('time'));

                                  ref1.putClass(sTID("timeline"));

                                  desc1.putReference(cTID('null'), ref1);

                                  var desc2 = new ActionDescriptor();

                                  desc2.putInteger(sTID("seconds"), 4);

                                  desc2.putInteger(sTID("frame"), 29);

                                  desc2.putDouble(sTID("frameRate"), 30);

                                  desc1.putObject(cTID('T   '), sTID("timecode"), desc2);

                                  executeAction(cTID('setd'), desc1, dialogMode);

                                };

                              • 13. Re: Action script does not working
                                JJMack Most Valuable Participant

                                Where is the rest of you script.  What you posted is a script  function made form scriptlistener action manager code on its own it will do nothing.

                                 

                                To start a discussion in Photoshop scripting use the link under Actions in Photoshop Scripting Content page on the left Start a discussion.

                                • 14. Re: Action script does not working
                                  naeema79951470 Level 1

                                  thank you for replying Mack! here is the complete code, this is to go to start of working area in timeline in photoshop

                                  //==================== Set ==============

                                  //

                                  function Set() {

                                    // Set

                                    function step1(enabled, withDialog) {

                                      if (enabled != undefined && !enabled)

                                        return;

                                      var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                      var desc1 = new ActionDescriptor();

                                      var ref1 = new ActionReference();

                                      ref1.putProperty(cTID('Prpr'), cTID('time'));

                                      ref1.putClass(sTID("timeline"));

                                      desc1.putReference(cTID('null'), ref1);

                                      var desc2 = new ActionDescriptor();

                                      desc2.putInteger(sTID("seconds"), 4);

                                      desc2.putInteger(sTID("frame"), 29);

                                      desc2.putDouble(sTID("frameRate"), 30);

                                      desc1.putObject(cTID('T   '), sTID("timecode"), desc2);

                                      executeAction(cTID('setd'), desc1, dialogMode);

                                    };

                                   

                                    step1();      // Set

                                  };

                                  • 15. Re: Action script does not working
                                    naeema79951470 Level 1

                                    it works as an action but not as a script

                                    • 16. Re: Action script does not working
                                      JJMack Most Valuable Participant

                                      It look like you used X's ActionFileToJavascript.jsx  and edited the jsx  file that was crerated delete required functions.  Your script now is only a Set function that is never used and if it where used step1 will fail for you deleted functions cTID and sTID.

                                      • 17. Re: Action script does not working
                                        naeema79951470 Level 1

                                        this is part of a longer code but do you want me to add that in here as well? it might be long, I dont want to complicate it for you but just incase you want it anyway ok I will put everything in

                                         

                                          // Select

                                          function step1(enabled, withDialog) {

                                            if (enabled != undefined && !enabled)

                                              return;

                                            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                            var desc1 = new ActionDescriptor();

                                            var ref1 = new ActionReference();

                                            ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Back'));

                                            desc1.putReference(cTID('null'), ref1);

                                            desc1.putBoolean(cTID('MkVs'), false);

                                            var list1 = new ActionList();

                                            list1.putInteger(1);

                                            desc1.putList(cTID('LyrI'), list1);

                                            executeAction(cTID('slct'), desc1, dialogMode);

                                          };

                                         

                                          // Select

                                          function step2(enabled, withDialog) {

                                            if (enabled != undefined && !enabled)

                                              return;

                                            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                            var desc1 = new ActionDescriptor();

                                            var ref1 = new ActionReference();

                                            ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Frwr'));

                                            desc1.putReference(cTID('null'), ref1);

                                            desc1.putBoolean(cTID('MkVs'), false);

                                            var list1 = new ActionList();

                                            list1.putInteger(8);

                                            desc1.putList(cTID('LyrI'), list1);

                                            executeAction(cTID('slct'), desc1, dialogMode);

                                          };

                                         

                                          // Create Video Timeline

                                          function step3(enabled, withDialog) {

                                            if (enabled != undefined && !enabled)

                                              return;

                                            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                            executeAction(sTID('makeTimeline'), undefined, dialogMode);

                                          };

                                         

                                          // Enable

                                          function step4(enabled, withDialog) {

                                            if (enabled != undefined && !enabled)

                                              return;

                                            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                            var desc1 = new ActionDescriptor();

                                            var ref1 = new ActionReference();

                                            ref1.putEnumerated(sTID("animationTrack"), sTID("stdTrackID"), sTID("sheetTransformTrack"));

                                            desc1.putReference(cTID('null'), ref1);

                                            executeAction(sTID('enable'), desc1, dialogMode);

                                          };

                                         

                                          // Set

                                          function step5(enabled, withDialog) {

                                            if (enabled != undefined && !enabled)

                                              return;

                                            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                            var desc1 = new ActionDescriptor();

                                            var ref1 = new ActionReference();

                                            ref1.putProperty(cTID('Prpr'), cTID('time'));

                                            ref1.putClass(sTID("timeline"));

                                            desc1.putReference(cTID('null'), ref1);

                                            var desc2 = new ActionDescriptor();

                                            desc2.putInteger(sTID("seconds"), 4);

                                            desc2.putInteger(sTID("frame"), 29);

                                            desc2.putDouble(sTID("frameRate"), 30);

                                            desc1.putObject(cTID('T   '), sTID("timecode"), desc2);

                                            executeAction(cTID('setd'), desc1, dialogMode);

                                          };

                                         

                                          // Transform

                                          function step6(enabled, withDialog) {

                                            if (enabled != undefined && !enabled)

                                              return;

                                            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                            var desc1 = new ActionDescriptor();

                                            desc1.putEnumerated(cTID('FTcs'), cTID('QCSt'), sTID("QCSAverage"));

                                            var desc2 = new ActionDescriptor();

                                            desc2.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), 4.2);

                                            desc2.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), -9.66442953020133);

                                            desc1.putObject(cTID('Ofst'), cTID('Ofst'), desc2);

                                            desc1.putUnitDouble(cTID('Wdth'), cTID('#Prc'), 108.033454590679);

                                            desc1.putUnitDouble(cTID('Hght'), cTID('#Prc'), 108.187590139748);

                                            executeAction(cTID('Trnf'), desc1, dialogMode);

                                          };

                                         

                                          // Set

                                          function step7(enabled, withDialog) {

                                            if (enabled != undefined && !enabled)

                                              return;

                                            var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

                                            var desc1 = new ActionDescriptor();

                                            var ref1 = new ActionReference();

                                            ref1.putProperty(cTID('Prpr'), cTID('time'));

                                            ref1.putClass(sTID("timeline"));

                                            desc1.putReference(cTID('null'), ref1);

                                            var desc2 = new ActionDescriptor();

                                            desc2.putInteger(sTID("seconds"), 0);

                                            desc2.putInteger(sTID("frame"), 0);

                                            desc2.putDouble(sTID("frameRate"), 30);

                                            desc1.putObject(cTID('T   '), sTID("timecode"), desc2);

                                            executeAction(cTID('setd'), desc1, dialogMode);

                                          };

                                         

                                          step1();      // Select

                                          step2();      // Select

                                          step3();      // Create Video Timeline

                                          step4();      // Enable

                                          step5();      // Set

                                          step6();      // Transform

                                          step7();      // Set

                                        };

                                        • 18. Re: Action script does not working
                                          naeema79951470 Level 1

                                          these functions cTID and sTID are in the top, so it does work, this entire code runs until it gets to the code of the set, the one which i posted first, that seems to be the issue as to why my script stops

                                          • 19. Re: Action script does not working
                                            naeema79951470 Level 1

                                            what this does is it selects a image layer, then it creates a video timeline, then it creates keyframe of the image, it transforms the size a bit bigger, thats all

                                            • 20. Re: Action script does not working
                                              JJMack Most Valuable Participant

                                              What you posted here does not work without the two functions.  The first function you posted was a step5 set frame rate to 30 FPS.  Your second post a set function that had and inner function Step1 set frame rate 30FPS.  The last again missing the two functions that two set steps that set frame rate 30FPS.

                                               

                                              Your script should ends after the last set step.  Did you run the script on a document like the document  you recorded the action on? So all the steps will work?

                                               

                                              Were the two select done, the video timeline created, was the transform keyframe enabled at the beginning of the video, why a sets frame rate 30fps before and the transform.

                                               

                                              Was the transform done correctly are the values valid for the document you ran the script on?

                                               

                                              which set frame rate 30fps step stopped the first one or the second one?

                                              • 21. Re: Action script does not working
                                                naeema79951470 Level 1

                                                yes those two functions are not pasted here cause in my document its right at the top, so cant paste it here its too long of a document, the whole script runs but not the set part, the transform is done correctly, if i record the transform alone, then run a script then it works, so that is why I know it has to be the set functions causing the issues, cause i tested the set function alone as well, it works only in the action, but not in the script, this whole jsx is to be applied on to a workflow that consist of 5 layers, so it selects the second last one and then apply this script

                                                • 22. Re: Action script does not working
                                                  naeema79951470 Level 1

                                                  the condition or scenario is right, cause with the action, it works but script doe not, same thing, just the script dont work, what i do is i run the action, it works, then undo and try the script, then it dont work, there are two sets, one goes to end of timeline, then other goes back to start

                                                  • 23. Re: Action script does not working
                                                    naeema79951470 Level 1

                                                    the condition or scenario is right, cause with the action, it works but script doe not, same thing, just the script dont work, what i do is i run the action, it works, then undo and try the script, then it dont work, there are two sets, one goes to end of timeline, then other goes back to start