Copy link to clipboard
Copied
I created a script that installs Action
if stock exists must leave everything unchanged
otherwise you must install it.
Amend actionSetName to suit.
...#target photoshop;
var as = getActionSets();
var aSet = File(Folder.desktop + "/actionSetName.atn");
var Loaded = false;
for (var a in as){
if(as.match(/actionSetName/i)){
Loaded = true;
break;
}
}
if(!Loaded) app.load(aSet);
function getActionSets(){
var aSets=[];
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), 1);
var desc = executeActionGet(ref);
var Count = desc.getInteger(stringIDToTypeID("count")) + 1;
for(var t=1; t<=Count; t++){
var re
Copy link to clipboard
Copied
explain what you mean when you write "if stock exists"...
Copy link to clipboard
Copied
I created a script that installs Action
if Action exists must leave everything unchanged
otherwise you must install it.
Copy link to clipboard
Copied
Action are loaded via *.ATN file action set. So the can contain one or more actions. Also different action sets can contain action with the same names as other action sets have. These could be the same of different action. You cal load an action set with the same name as a loaded action set. The set could contain the same actions, different actions od different version of some actions.
I think you would need to deal with the from an Action Set standpoint. Have some way to determine it the set loaded is the current version.
Also users can edit Actions add action to an action set and delete actions in an loaded action set. If an action does not exist on a machine for some user and you load a set there may now be multiple sets loaded with that name. If you delete the set first you may delete actions the users has added. The user may have deleted the missing action for the did not want to use it use it their work-flow. If you are trying to write the script for a community of users you may not be able to develop the perfect script. If it is just for your own use you control your work-flow.
Copy link to clipboard
Copied
the problem and this
Room button if I click on the install action and this action and existing script adds another action
I would like it if the set action, and this must not add the set of the same name
Copy link to clipboard
Copied
Not sure if it is exactly what you have in mind, but here is some code which might be useful:
// Adapted from: jamUtils.loadActionSet
// <http://blog.tonton-pixel.com/json-photoshop-scripting/json-action-manager/>
// <http://blog.tonton-pixel.com/JSON%20Action%20Manager/jsDoc/symbols/jamUtils.html>
//
// Load an action set if not currently available.
// actionSet: action set name string
// actionsFilePath: actions file path string
//
function loadActionSet (actionSet, actionsFilePath)
{
try
{
var ref = new ActionReference ();
ref.putName (app.stringIDToTypeID ("actionSet"), actionSet);
app.executeActionGet (ref);
var found = true;
}
catch (e)
{
var found = false;
}
if (!found)
{
var desc = new ActionDescriptor ();
desc.putPath (app.stringIDToTypeID ("target"), new File (actionsFilePath));
app.executeAction (app.stringIDToTypeID ("open"), desc);
}
};
//
// Example:
Folder.current = new Folder ("~/JSON Action Manager/tests/resources/");
loadActionSet ("Cross Processing", "Cross Processing.atn");
//
HTH,
--Mikaeru
Copy link to clipboard
Copied
I'm sorry but it is not what I need.
I need a script that controls the action
if this action and nothing happens
if not present must install a personnel action
Copy link to clipboard
Copied
Amend actionSetName to suit.
#target photoshop;
var as = getActionSets();
var aSet = File(Folder.desktop + "/actionSetName.atn");
var Loaded = false;
for (var a in as){
if(as.match(/actionSetName/i)){
Loaded = true;
break;
}
}
if(!Loaded) app.load(aSet);
function getActionSets(){
var aSets=[];
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), 1);
var desc = executeActionGet(ref);
var Count = desc.getInteger(stringIDToTypeID("count")) + 1;
for(var t=1; t<=Count; t++){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), t);
var desc = executeActionGet(ref);
var actName = desc.getString(charIDToTypeID('Nm '));
aSets.push(actName);
}
return aSets;
};
Copy link to clipboard
Copied
SuperMerlin
Your script and the one I use
if you run it the first time is fine charging action
if you run it again charging action and find myself with more copies of the same action
I would like it if this action and should not be loaded
if not present and the charge.
I know my English and poor but I can not do better.
Copy link to clipboard
Copied
Have you have changed line 2 and line 6 for actionSetName to your actionSet name?
If your actionSet name is found it will not load the actionset.
Copy link to clipboard
Copied
I had not changed the name action line 6
it works fine
thank you
Copy link to clipboard
Copied
The script works perfectly
untima a question
I would put the script into the folder where this action
I tried to change this string but does not work
var = aSet File (scriptFolder + "/actions/actionSetName.atn");
where I'm wrong
Copy link to clipboard
Copied
var SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize('$$$/ScriptingSupport/InstalledScripts=Presets/Scripts'));
var = aSet File (SCRIPTS_FOLDER + "/actions/actionSetName.atn");
Copy link to clipboard
Copied
SuperMerlin
the action and script are in the same folder
This is a picture
I wish that were installed Actions_1.atn
Copy link to clipboard
Copied
#target photoshop;
var as = getActionSets();
var aSet = File(whereAmI() + "/Actions_1.atn");
var Loaded = false;
for (var a in as){
Loaded = true;
break;
}
}
if(!Loaded) app.load(aSet);
function whereAmI(){
var where
try {
app.documents.test();
}
catch (err){
where = File(err.fileName);
}
return where.path;
};
function getActionSets(){
var aSets=[];
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), 1);
var desc = executeActionGet(ref);
var Count = desc.getInteger(stringIDToTypeID("count")) + 1;
for(var t=1; t<=Count; t++){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), t);
var desc = executeActionGet(ref);
var actName = desc.getString(charIDToTypeID('Nm '));
aSets.push(actName);
}
return aSets;
};
Copy link to clipboard
Copied
SuperMerlin
Thank you
Copy link to clipboard
Copied
As I wrote if the script is just for your use you can most likely script something that will work for you. You can not change the way Photoshop work or how others use Photoshop. Photoshop Actions Palette allows duplicate actions set names to be loaded. Users can Add, Delete and edit Actions in Action sets. I do not believe a script can examine a action see its steps to make sure it the correct action with the correct steps and and has not been modified.
Personally I do not know why you would want to script something like that for your own use for after all you control you Photoshop environment and install your add-ons in the first place. You should know what in the Actions palette.
Copy link to clipboard
Copied
tssee@imgof.com wrote
I created a script that installs Action
if stock exists must leave everything unchanged
otherwise you must install it.
Please post the script you created so we get some idea of what you have coded.