# Converting old action to New Photoshop version 22 Alchemist batch code

**URL:** <https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367>\
**Category:** Photoshop\
**Created:** [July 24, 2021, 12:23am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367 "2021-07-24T00:23:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcotto](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@dcotto](https://forums.creativeclouddeveloper.com/u/dcotto)\
**Post date:** [July 24, 2021, 12:23am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/1 "2021-07-24T00:23:13Z")

</div>

Hello,  
im having an issue where when my code hits this portion of code it crashes Photoshop version 22.  
Im trying to resolve the issue. Does anyone know what photoshop command this is exactly? What can i click or what button combination can i press to generate the below code? Is it possible for someone out there to convert this code to the new one using the alchemist plugin? Any help would help.  
Thank you so much

```auto
    function command() {
        var desc143 = new ActionDescriptor();
        var ref73 = new ActionReference();
        ref73.putClass(charIDToTypeID('Dcmn'));
        desc143.putReference(charIDToTypeID('null'), ref73);
        desc143.putString(charIDToTypeID('Nm '), activeDocument.activeLayer.name);
        var ref74 = new ActionReference();
        ref74.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
        desc143.putReference(charIDToTypeID('Usng'), ref74);
        executeAction(charIDToTypeID('Mk '), desc143, DialogModes.NO);
    }

```

---

<div class="post-metadata">

**Author:** ![Pierre\_G](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pierre_g/32/971_2.png) [@Pierre\_G](https://forums.creativeclouddeveloper.com/u/Pierre_G)\
**Post date:** [July 24, 2021, 12:34am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/2 "2021-07-24T00:34:47Z")

</div>

Are you trying to rename a layer ?

---

<div class="post-metadata">

**Author:** ![dcotto](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@dcotto](https://forums.creativeclouddeveloper.com/u/dcotto)\
**Post date:** [July 24, 2021, 12:38am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/3 "2021-07-24T00:38:52Z")

</div>

here in this site, someone named it dupLayers();  
This is a snip of code i grabbed online thats part of a bigger operation.

> **[Re: Export layer to a folder:](https://community.adobe.com/t5/photoshop-ecosystem/export-layer-to-a-folder/m-p/9434286)**
>
> Ah, in that case the script would be... #target photoshop;  if(documents.length) main();  function main(){  var OutputFolder =Folder("/C/myfolder/"); if(!OutputFolder.exists) OutputFolder.create(); var LayerName =...

what the bigger operation does is basically grab a layer, copies it to a new document and saves the file. im not sure if this code is duplicating the layer and sending it to a new document but overall, thats the process and this code is part of that

---

<div class="post-metadata">

**Author:** ![dcotto](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@dcotto](https://forums.creativeclouddeveloper.com/u/dcotto)\
**Post date:** [July 24, 2021, 1:29am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/4 "2021-07-24T01:29:25Z")

</div>

i figured out what it was doing… its duplicating the layer and sending it to new document… its equivalent to right clicking a layer \> selecting “duplicate layer/artboard” and in the popup selecting \> Document: “new”. What i dont understand is why is photoshop crashing at this point… in older versions it doesnt crash. i dont think i can use the code that alchemist is using because i am using CEP (i believe) the old extendscript/legacy dev enviroment. Is there a way for alchemist to pump out old legacy code instead? im not sure how to proceed

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [July 24, 2021, 9:19am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/5 "2021-07-24T09:19:37Z")

</div>

You could try Humanizer. This way you can use code very similar to the modern batchPlay. It is very similar but you might need to do some adjustments. E.g. in reference [GitHub - jardicc/ActionManagerHumanizer: This tool will reveal for you occult mystery of Photoshop ActionDescriptors and will transform them into well known JSON strings and JS objects](https://github.com/jardicc/ActionManagerHumanizer#and-here-is-how-our-output-looks-like)

---

<div class="post-metadata">

**Author:** ![dcotto](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@dcotto](https://forums.creativeclouddeveloper.com/u/dcotto)\
**Post date:** [July 25, 2021, 4:07am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/6 "2021-07-25T04:07:36Z")

</div>

Thank you, it looks promising,  
But everytime i include the Humanizer.jsx my whole script fails.

so if i use:  
//@include Humanizer.jsx or #include Humanizer.jsx

it fails.

I have the Humanizer.jsx file alongside my index.jsx file.

When i go back and remove the include statement above, my code goes back to working.

My whole project and folder structure is based off this one:

> **[How to create your first Adobe panel in 6 easy steps](https://blog.developer.adobe.com/how-to-create-your-first-adobe-panel-in-6-easy-steps-f8bd4ed5778?gi=ed68da5b81bc)**
>
> Build your first plug-in for Photoshop by following these 6 easy steps.

i think one of the issues is that its using JSON object. I dont think the JSON object exists in this old Adobe Photoshop CEP API. The JavaScript it uses is ECMAScript version 3 i believe. its very old school version. so not sure if thats an issue.

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [July 25, 2021, 9:23am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/7 "2021-07-25T09:23:16Z")

</div>

Yes you need additional polyfil

---

<div class="post-metadata">

**Author:** ![dcotto](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@dcotto](https://forums.creativeclouddeveloper.com/u/dcotto)\
**Post date:** [July 25, 2021, 11:58am UTC](https://forums.creativeclouddeveloper.com/t/converting-old-action-to-new-photoshop-version-22-alchemist-batch-code/3367/8 "2021-07-25T11:58:33Z")

</div>

I see, would you happen to know all the polyfills required for this plug-in? Just wondering. Thanks
