• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to Save Work Path as Normal Path

Community Beginner ,
Feb 15, 2017 Feb 15, 2017

Copy link to clipboard

Copied

Hi, I am totally new to scripting. I thought I would try to work out something simple first, to get my feet wet. But I can't seem to understand how to make the script do what I want. Essentially, I just need it to see if there is a work path in the document, and, if so, save it as a normal path.  Any help would be appreciated.

If it matters, I have been trying to do this in Java. I may give Applescript a shot later.


Thanks,

TOPICS
Actions and scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Engaged , Feb 15, 2017 Feb 15, 2017

Hi tJohnson,

Try this code...

activeDocument.pathItems.getByName("Work Path").name="Path 1";

- yajiv

Votes

Translate

Translate
Community Expert , Feb 16, 2017 Feb 16, 2017

I would wrap that code in a try/catch block, as if there isn't a workpath, an error would be thrown. You could also change the name to:

.name = 'path ' + activeDocument.pathItems.length

in an attempt to auto name the path, so if you happen to already have a Path 1, the dialogbox won't come up to have you rename the path.

Votes

Translate

Translate
Adobe
Engaged ,
Feb 15, 2017 Feb 15, 2017

Copy link to clipboard

Copied

Hi tJohnson,

Try this code...

activeDocument.pathItems.getByName("Work Path").name="Path 1";

- yajiv

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2017 Feb 16, 2017

Copy link to clipboard

Copied

I would wrap that code in a try/catch block, as if there isn't a workpath, an error would be thrown. You could also change the name to:

.name = 'path ' + activeDocument.pathItems.length

in an attempt to auto name the path, so if you happen to already have a Path 1, the dialogbox won't come up to have you rename the path.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Cool, I didn't know that's so easy, so I always used Action Managet to change name of paths 😕

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 20, 2017 Feb 20, 2017

Copy link to clipboard

Copied

Thanks folks. Between the two of you I was able to get it to do exactly what I wanted (and a bit more, even).

In case anyone else comes along looking for the same bit of code, here's what worked for me:

#target photoshop

app.bringToFront();

try {

    activeDocument.pathItems.getByName("Work Path").name="Path " + activeDocument.pathItems.length;

    }

catch (Exception) {}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Unfortunately for me right now, when I rename the Work Path in a document I'm processing, it for some reason removes the 'path' line of the path. I'm going to have to try utilizing an action to perform the 'save path' command.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

UPDATE: I was able to fix this by using the PathItem.select() method to ensure the path is first selected in the Paths panel before renaming. Then the path content stays. However I discovered another issue which caused the path to be cleared due to my follow-up action which has to run (it's an action from somebody else). In order to fix this new issue I used the PathItem.deselect() method which made the path not be cleared by whatever the follow-up action does.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

LATEST

So maybe if it's not your action, then that other one deletes path only when it's selected 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines