Variables in an action to use in script

I want to duplicate an image, then change the duplicated image name to the original image name with some extra text at the end to make it slightly different.
Example.
Original..    Image123
Duplicate...  Image123BW. Or Image123BG. etc.
So as not to have to have a separate script for each different text addition I wondered if I can have a variable in the action that can be passed to the script to add to the new document name?

Code to duplicate document:
var doc = app.activeDocument
var fname = doc.name.split(".")
var fname = fname[0]
var ToneType = 'BW'
var newDoc = doc.duplicate(fname+ToneType,true)
//var newDoc = doc.duplicate(fname,true)
newDoc.flatten();
I have 3 actions that I want to use the script for. One action to make a B&W (BW), one for Sepia (SP), one for Warm B&W (WBW). If I use the above code it will just duplicate the document with the same name, adding the hardcoded ToneType to the end of the document name. I could make three scripts, one for each, but I thought if I could have a variable (ToneType = 'BW') for example, that would pass to the script then I could only use one script that would change depending on the variable name that was in the action.
This code will just duplicate the document without the text  COPY  at the end but I need to make one for each ToneType I have. Maybe that's the easiest way but I like to make a script with multiple uses.
When you suggested that rename the active layer with a specific name, I can rename the background layer to  BW  for example, but at the end I still need to rename the file with the   BW . I can script the part to add the active layer to the document name but can't figure out how to replace the name when the script goes back to Photoshop.  I know something is missing in this code that will replace the active documents name. Just not sure what.
this is the code for that try:
//replace name of current document with document name + active layer name
layerN = activeDocument.activeLayer.name
var doc = app.activeDocument
var fname = doc.name.split(".")
var fname = fname[0]
app.activeDocument.name = (fname+layerN,true)
Thanks for any help!

Similar Messages

  • How to pass values to variables in WAD 7.0 using java script

    Hi.,
    My requirement is based on WAD 7.0.
    The sales value has to displayed in WAD using graph with various chart types.
    I have created variables for plant and material group in a query.
    I have created drop down box for plant with all plants in it, check box for material group and a Submit button in WAD in FORM tag of HTML coding.
    Once all the values are set in drop down box, checkbox and if the user clicks on submit button, the values has to captured by the variables for which I have created and the graph has to be aligned to the new values in variables.
    Kindly help me how to use java script to get the values from FORM and pass it to variables.
    Regards,
    Selva

    Hi Selva,
    You do not need to use Javascript for this. Instead you can achieve this by using API Commands in WAD 7.0.
    Please configure Action on the ButtonGroup webitem to use 'Commands'.
    ->Choose Command 'Set Variables Values / SET_VARIABLES_STATE' under Commands for Web Templates
    ->Set Display Variable Screen setting to OFF
    ->Choose Query Variable for Plant, Select Variable Type as 'Binding Type', Binding Type as 'Data Provider Selection', Data Provider as the one you have assigned to the Dropdown webitem, Characteristic as 0PLANT or as that assigned to the Dropdown webitem
    ->Repeat above steps for Query Variable Material Group
    Now when you make a selection from the Dropdown webitems, the Chart output will change accordingly. Let me know if this helps.
    --Priya

  • Clearing the actions panel and loading an action set using a script.

    I've been trying to figure out how to do this now for two days straight, I'm still completely stuck and can't manage to do it. Scriptlistener shows nothing for the "Clear actions" and "Load actions" menu items when the function is called in both CS5 and CS3 and both JS and VBS.
    Does anyone here have a solution? Any scripts?
    Thank you so much.

    This should help...
    //get a list of all actionSets
    var actionList =getActionSets();
    //remove all actionSets
    for(var d in actionList){
    unLoadAction(actionList[d]);
    //Load your new actionSet
    app.load(File("/c/actions/myNewAtionset.atn"));
    function getActionSets() {
    cTID = function(s) { return app.charIDToTypeID(s); };
      var i = 1;
      var sets = []; 
      while (true) {
        var ref = new ActionReference();
        ref.putIndex(cTID("ASet"), i);
        var desc;
        var lvl = $.level;
        $.level = 0;
        try {
          desc = executeActionGet(ref);
        } catch (e) {
          break;
        } finally {
          $.level = lvl;
        if (desc.hasKey(cTID("Nm  "))) {
          var set = {};
          set.index = i;
          set.name = desc.getString(cTID("Nm  "));
          set.toString = function() { return this.name; };
          set.count = desc.getInteger(cTID("NmbC"));
          set.actions = [];
          for (var j = 1; j <= set.count; j++) {
            var ref = new ActionReference();
            ref.putIndex(cTID('Actn'), j);
            ref.putIndex(cTID('ASet'), set.index);
            var adesc = executeActionGet(ref);
            var actName = adesc.getString(cTID('Nm  '));
            set.actions.push(actName);
          sets.push(set);
        i++;
      return sets;
    function unLoadAction(aSet){
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putName( charIDToTypeID( "ASet" ), decodeURI(aSet));
    desc.putReference( charIDToTypeID( "null" ), ref );
    executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );

  • Use of Essbase substitution variables in filename of a MaxL report script

    Hey guys.
    Is there a way that I can embed the value of one or more Essbase substitution variables in the filename of a report script in a MaxL command?
    I'm running a report script that uses sub. vars for entities and accounts and based on which of those members are set in the variables I want the filenames to include those member names. I'm looking for a way to include the &varName in the filename using the export database command.
    THANKS!

    Not really.
    If you want to do a lot of string mangling in a script outside of the report script, you can use DISPLAY VARIABLE:
    MAXL> display variable CurMo;
    application         database            variable            value
    +-------------------+-------------------+-------------------+-------------------
                                             CurMo               MayRegards,
    Robb Salzmann

  • How to load a variable using MATLAB Script?

    I need to load a selected variable from .mat file, using MATLAB script , and analyse it.
    the attched shows my vi, there are two inputs nodes 'file' contains the .mat file path, and 'varn' contains varibale name in that .mat file which can be selected by user. Using " load(file)" the whole .mat file is loaded in the workspace and become avaiable at output node, however I am not able to pass a selected variable name through string "varn" input, MATLAB script does not recognize the variable.
    any idea to reslove it is realy appreciated.
    Attachments:
    load a variable.JPG ‏18 KB

    Download the VI and .MAT file. Run the VI, and it'll plot the data inside of the .MAT file.
    Andy Chang
    National Instruments
    LabVIEW Control Design and Simulation
    Attachments:
    testfile.zip ‏5 KB

  • Create local variable using labview scripting

    I am trying to use labview scripting to create a control and a local variable for that control.  I want both the local variable and the control contained inside a case structure.  My problems are twofold:
    1. the local variable is left blank/unnamed
    2. the local variable is wired outside of the case structure, even though I set it's owner to be the same as the owner for the control (which is placed inside the case structure).
    The flat panel is there because I thought that my problem might be a result of the local var being created before the actual control, so this just forces the control to be created first.  The other thing I wonder about is the VI Object Class for the local variable.  I have tried 'Node' and Control->Boolean, but neither worked.
    I have attached a jpg of the code I'm talking about.  The picture on thetop is of the code in question.  The picture on the bottom is of the resulting code that's created....
    Can anyone offer any help?
    Thank you...
    Attachments:
    vi_scripting_lv.png ‏95 KB

    The reason your locals aren't tied to a control, is because you didn't make a local variable from any control.  Use the Boolean reference wire and wire it to an Invoke Node and select the Create >> Local Variable method.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Is it possible to use a Script within an action? - it doesn't seem to work...

    Is it possible to use a Script within an action? - it doesn't seem to work...
    I'm using the 'round any corner' script from SATO Hiroyuki..., and  I'd like to apply it to only one anchor point (on multiple boxes)

    An Action can call a script from the File>Scripts menu by means of the Add Menu Item Action step. But it will only work for the duration of your Illustrator work session. If you quit AI and then restart it, the Add Menu Item step will be blank. This bug has been reported for FOUR FULL VERSIONS of this sloppy program.
    However, if I am correctly understanding your description of what you are trying to automate, an Action will not be able to automate the selection of a particular anchorpoint in multiple paths. You'd have to make the selections all at first. Whether the script would then apply as desired to each path depends on how the script is written.
    JET

  • Help: Need  script help to delete hidden layers. Action errors using panel command.

    I am trying to make an action (that is using some scripts) that will delete hidden layers. When I try and action that in photoshop, the actions stops for an error if the file didn't have any hidden layers. I think I need to script it so it will delete the hidden layers, and keep going if there aen't any.
    I couldnt find anything in th ejavascript ref guide for doing this. ( I'm sure I was looking right at it, I am a noob).
    Thanks for any help you can give.

    Here is a script to will delete hidden layers but not throw an error is there are no hidden layers.
    try{
         var desc = new ActionDescriptor();
         var ref = new ActionReference();
         ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), stringIDToTypeID( "hidden" ) );
         desc.putReference( charIDToTypeID( "null" ), ref );
         executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );
    }catch(e){}
    Note you could also do this with just actions steps. Have the action add a layer then hide it before the delete hidden layers menu item step. That way there would always be at least one hidden layer and no error.

  • Query about User Variables and Advanced Actions

    Hello,
    I am creating a clinical-based project using Captivate 5.I have to give you quite a bit of information before I can pose my questions so please bear with me.
    Users have to select multiple options from a checkbox widget (shown below).
    Each options, for example 'location' is associated with a variable for example 'hpi0' (See below):
    Each option has addtional data associated with it:
    Location = hpi0 (user variable)
    Location data = hpi0data (user variable)
    Please see the screenshot below:
    Notice in the image above that I have created a conditional advanced action - if the user selects Location (hpi0) on the checkbox widget, the data associated with that variable will be presented to them. That data (e.g. location data or hpi0data) is presented in a caption text box in the following slide. (see below)
    I hope I have given you enough information.This is a complex project and this is just one of my many problems.I have had to create over 200 hundred user variables and more than 6 Conditional Advanced Actions in one project. The project is becoming unstable. So here are my queries:
    1) Are there limits to the amount of user varables I can create in a project?
    2) If so, how can I re-use the user variables I have already created? Otherwise I will have to divide this project into 3 parts and I want to avoid doing that.
    3) Are there limits to the amount of Advanced actions I can create in a project?
    Again  I am using Captivate 5 for this project.
    Any assistance, tips or tricks would be greatly appreciated. I am learning captivate as I go so If there is away to streamline this process, I am open to any suggestions.
    Thanks
    Tinukwa

    Hello Tinukwa
    This is indeed a challenging project, and although I did create a lot of projects with advanced actions, they were never that size. You have to listen to Jim's words about using some widgets, he is a widget specialist which I'm not. I do not know if you are aware of the fact that the checkboxes widget coming with Cp was extended by Jim? He offers it on his website, I blogged about this extension and suppose you do know my blog. About the advanced actions, perhaps I could help but only screenshots are bit limited. So I wonder if either I could have access to the file and/or if we could have a Connect session eventually?
    First intuition tells me
    we should look to re-use variables, but I do need more information; do you need the vars XXXXdata somewhere else later? If not, perhaps only to display it you could use one variable; now you keep the information chosen by the user in 2 variables: hpi0 and hpi0data (isn't that redundancy?)
    and by choosing labels for variables, actions and objects in an intelligent way reduce the editing time because you'll need a lot of almost identical advanced actions. Usually I do a lot of reflection before starting to create labels, variables and actions.
    About re-using what you already constructed: as I explained once, a template is the only way to be able to re-use a script at the moment. And Kevin Siegel discovered (so gratefully for that) it is possible just to change the extension of a standard CP file to cptl to have a template.
    Lilybiri
    PS Jim suggest also to split up the project? Here I'm not sure if that is really needed.. should have been the case for previous versions.

  • Display data vertically using sap script

    Hi Developers,
    Is there any way to display data vertically in a form using sap script?
    thanx in advance,
    binu

    Hi Binu,
    It is not possible to rotate text in SAPscript.  The usual work-around, provided this is static text and not from a variable, is to scan an image of the text and include it as a graphic.
    Regards,
    Nick

  • Sending email using apple script...

    I have created a watch folder using apple script that when a file is dropped on it, it automatically opens, formats, and sends out a custom email.
    What I don't understand is, how can I include multiple variables in the "content" section (also known as the body section of the email)? I want to put custom type in the content section that says "There is a file awaiting your review." I also would like to choose an email signature from my mail program to use. Third, I would like to include the name of the file that is being sent....
    I found that by doing {content:iteminfo} I could get the file name...If I do {content:"There is a file awaiting your review."} I could get the custom type I wanted....
    BUT, I can't figure out how to get BOTH of them together in ADDITION to adding a custom email signature...
    I know there are some really smart people out there...Any tips?

    I can't figure out how to get BOTH of them together
    This is just standard AppleScript text concatenation with the &:
    ... {content: "There is a file awaiting your review: " & iteminfo}
    Here you can see I'm concatenating a literal string (enclosed in quotes) and a variable. You can extend this ad infinitum.
    As for the signature:
    tell theMessage to set message signature to signature "My Sig"
    (which assumes you have a signature named 'My Sig'. Adjust as necessary.

  • Using a script object

    Hi,
    I have beginner skills using LC Designer ES and am trying to insert and use a script object. I found a JavaScript function online: http://home.online.no/~pjacklam/notes/invnorm/impl/misra/normsinv.html and am trying to get it to do some math calculations in a Designer form.
    I've uploaded a sample test form at: http://elearningprojects.com/TestFormula1.pdf
    Can't get it to work.Trying to run the JS formula in the script object (by clicking on a button), using a few hard-coded variables, and display the results (Dprime1 and Dprime2) in 2 text fields.
    I would much appreciate if someone can take a look and suggest how to get it working correctly.
    Thanks for your help.
    Kind Regards,
    saratogacoach

    Hi Paul,
    Thank you for your reply and suggestions. With beginner skills in LC Designer (I'm a retired social worker), I am not sure how to do this.
    Is my identifying the script object path correct?
    form1.#subform[0].#variables[0].SO1.function_name(NORMSINV(p));
    When you say "You are calling this function a few times in your code so you will have to modify each call." I am not sure how to change this.
    I currently have (note that I added the SO1. to the function calls):
    var p = totalscore5
    var probit1 = SO1.NORMSINV(p)
    var p = totalscore6
    var probit2 = SO1.NORMSINV(p)
    var Dprime1 = probit1-probit2
    var p = totalscore8
    var probit3 = SO1.NORMSINV(p)
    var p = totalscore7
    var probit4 = SO1.NORMSINV(p)
    var Dprime2 = probit3-probit4
    Can you specify what a modified script would look like? I'm stuck.
    Also, have I set up displaying the Dprime1 variable's value in the TextField1 correctly?
    Thanks very much for your help.
    Regards,
    saratogacoach

  • Setting Environment Variable not pulling in certain portion of script

    We have multiple domain controllers and when a user gets locked out constantly it is a bit of a process to login to that domain controller, pull the event logs, and search through that way. I looked at a few ways to automate this process in powershell and
    tweaked it a bit to work the way we need it to. I am trying to make this a simplified process for people who will use this script, currently I have:
    $DC = Read-Host "Domain Controller"
    $Account = Read-Host "Username"
    Get-WinEvent -ComputerName $DC -FilterHashtable @{Logname='Security';Data='$Account'} -MaxEvents 4 | Format-List -Property ID, TimeCreated, MachineName, Message
    This seems to work perfectly for what we need except when entering the information in response to Read-Host for $Account. The $DC pulls correctly but the $Account doesn't (I found this out by entering the user's username in the data field instead of $Account
    and the script worked correctly). Any Ideas on how to get this to work?

    Most answers are easy.  It is the questions that are hard.  If you had asked the right question you would have seen the answer immediately.
    Ask, "What is the difference between single and double quotes?"  When and why do variables need quotes?  Why and when do strings need quotes? 
    These are all PowerShell 101.  You must learn and understand to use PowerShell effectively
    \_(ツ)_/

  • Access a variable in the Adobe form for Java Scripting

    Hi,
    I am unable to know how to access the variable in a Adobe form.
    The variable is field of an internal table. My adobe form structure is as follows
    MAIN_PAGE->FORMSET->FirstFORM->EXT.
    in the EXT subform the variable(cust)  exists.
    The cust is in turn an internal table.

    Hello Sreelatha,
    I think we cannot hide a page.  as in, page is the main container.  In a container, we can hide any field using some scripting.  Even though if we hide the field, it is present on page but not visible. 
    but if some logic is there, please let me know.
    Thanks,
    Rakesh.
    Edited by: rakhi966 on Sep 8, 2011 8:54 PM

  • Assigning values to repeating subforms using a script

    I am using a script to add values to a repeating subform. Below is a simple example. In the real script I would use a loop to do the inserts.
    //declare XML structure
    String hrxdproot = /process_data/hrxfaform/object/data/xdp/datasets/data/form1";
    //assigning repeating subform number
    int i = 1;
    //assign a value to the first repeating subform
    patExecContext.setProcessDataStringValue(hrxdproot + "/Details[" + i +"]/employee_name", "Aditya");
    However, the error I get is
    "Target exception: org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. "
    I also tried to use a SetValue module to perform the same function and got the above error.
    /process_data/hrxfaform/object/data/xdp/datasets/data/form1/Details[1]/employee_name = "Aditya"
    Finally, I manually merged a sample xml (with 2 instances of the repeating subform) with the pdf and it worked fine. So I don't think there is a problem in the XML.
    Can someone please help...
    Aditya

    But the question is wether or not you're going to dynamically add nodes to your structure. Even if the schema permits to have multiple nodes under a specific section, it's hard to use xPath to do that. For example if you have a structure like the following:
    <Root>
      <Node1/>
    </Root>
    and use the following xPath /process_data/xmlvar/Root/Node1/Child1, you're going to end up with the following:
    <Root>
      <Node1>
          <Child1>
       </Node1>
    </Root>
    Now if you try to add another node under child node with a similar xPath /process_data/xmlvar/Root/Node1/Child2, you're going to end up with the following:
    <Root>
      <Node1>
          <Child2>
       </Node1>
    </Root>
    It won't append the node, it will replace everything under Node 1.
    So if this is what you're trying to do (add multiple children nodes), then you would have to create the xml structure using standard DOM objects within a custom component or the script service and the set the resulted xml to an xml variable.
    I hope this clears thigns up.
    Jasmin

Maybe you are looking for