# How to load PS Actions through UXP

**URL:** <https://forums.creativeclouddeveloper.com/t/how-to-load-ps-actions-through-uxp/6491>\
**Category:** UXP Developer Tool\
**Tags:** javascript\
**Created:** [July 11, 2023, 9:58am UTC](https://forums.creativeclouddeveloper.com/t/how-to-load-ps-actions-through-uxp/6491 "2023-07-11T09:58:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dogukanJD](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/dogukanjd/32/3064_2.png) [@dogukanJD](https://forums.creativeclouddeveloper.com/u/dogukanJD)\
**Post date:** [July 11, 2023, 9:58am UTC](https://forums.creativeclouddeveloper.com/t/how-to-load-ps-actions-through-uxp/6491/1 "2023-07-11T09:58:00Z")

</div>

I want to load the actions on the path that I have specified in the script, but we cannot access the path directly through script via uxp (right?) and move the files there. Is there another way to take the actions from a path where the project is standing and load them into ps via script?

---

<div class="post-metadata">

**Author:** ![sttk3](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sttk3](https://forums.creativeclouddeveloper.com/u/sttk3)\
**Post date:** [July 11, 2023, 11:37am UTC](https://forums.creativeclouddeveloper.com/t/how-to-load-ps-actions-through-uxp/6491/2 "2023-07-11T11:37:53Z")

</div>

If you want the UXP script, you cannot get the path automatically as you say. It will be roughly the same code on this page.

- [What are the real possibilities of loading an action.atn file in the Action palette with UXP?](http://forums.creativeclouddeveloper.com/t/what-are-the-real-possibilities-of-loading-an-action-atn-file-in-the-action-palette-with-uxp/6040)

If it is a UXP plugin, you can specify the path as you like, so it can load an atn file in the same folder as the document you have open, for example.

```auto
const { localFileSystem } = require('uxp').storage ;
const { action, app, core } = require('photoshop') ;

const main = async () => {
  try {
    await core.executeAsModal(
      async (control) => {
        const doc = app.activeDocument ;
        if(doc == null) {
          app.showAlert(`Please execute with the document open.`) ;
          return ;
        }

        const docPath = doc.path ;
        if(docPath === '') {
          app.showAlert(`Please save the document and then execute it.`) ;
          return ;
        }

        // get atn file in same folder as active document
        const parentPath = path.dirname(docPath) ;
        const atnName = 'set1.atn' ;
        const atnPath = path.join(parentPath, atnName) ;
        const atnEntry = await localFileSystem.getEntryWithUrl(atnPath) ;

        // load an action set with the same name if it does not exist
        const actionSetName = path.basename(atnPath, '.atn') ;
        const whetherExistsActionSet = action.validateReference({_ref: 'actionSet', _name: actionSetName}) ;
        if(whetherExistsActionSet) {
          await app.showAlert(`No action set was loaded since it already exists.`) ;
          return ;
        } else {
          await app.open(atnEntry) ;
          await app.showAlert(`ActionSet '${actionSetName}' has been loaded.`) ;
        }
      }, 

      {'commandName': 'Load Action Set'}
    ) ;
  } catch(e) {
    await app.showAlert(e) ;
  }
} ;

```

---

<div class="post-metadata">

**Author:** ![dogukanJD](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/dogukanjd/32/3064_2.png) [@dogukanJD](https://forums.creativeclouddeveloper.com/u/dogukanJD)\
**Post date:** [July 11, 2023, 3:43pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-load-ps-actions-through-uxp/6491/3 "2023-07-11T15:43:01Z")

</div>

first of all thank you for your answer. However, in order to load the action by this code, my ps file must be registered, but what I want to do is to load the action from the path of the main script that I prepared for UXP.  
I understood your approach here, since we did not have direct access to the path, you tried to find the path from the doc, it makes sense, but what I need is to find the path where the script is located in this way.

---

<div class="post-metadata">

**Author:** ![sttk3](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sttk3](https://forums.creativeclouddeveloper.com/u/sttk3)\
**Post date:** [July 11, 2023, 10:14pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-load-ps-actions-through-uxp/6491/4 "2023-07-11T22:14:49Z")

</div>

Can you use ExtendScript instead? It is easier to achieve.

```auto
/**
  * @file load action set from atn file in same folder as active jsx script
  * @version 1.0.0
  * @author sttk3.com
  * @copyright © 2023 sttk3.com
*/

(function() {
  // get atn file in same folder as active jsx script
  var scriptFile = new File($.fileName) ;
  var parentPath = decodeURIComponent(scriptFile.parent.fullName) ;
  var actionSetName = 'set1' ;
  var atnName = actionSetName + '.atn' ;
  var atnPath = parentPath + '/' + atnName ;
  var atnEntry = new File(atnPath) ;
  
  if(atnEntry.exists) {
    app.load(atnEntry) ;
    alert("ActionSet '" + actionSetName + "' has been loaded.") ;
  }
})() ;

```

---

<div class="post-metadata">

**Author:** ![dogukanJD](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/dogukanjd/32/3064_2.png) [@dogukanJD](https://forums.creativeclouddeveloper.com/u/dogukanJD)\
**Post date:** [July 12, 2023, 8:38am UTC](https://forums.creativeclouddeveloper.com/t/how-to-load-ps-actions-through-uxp/6491/5 "2023-07-12T08:38:27Z")

</div>

Haha actually what I was trying to do was move my project from extendScript to UXP. Thank you very much for your help, but I think we will follow the developments of UXP in this regard. (Thanks again for your support)
