How to export paths to AI in action / batch

New Here ,
Apr 14, 2020 Apr 14, 2020

Copy link to clipboard

Copied

Hi,

 

Ive recorded an action to export paths from adobe photoshop to Illustrator (ai files). It is working pretty well, but the action is exporting always to the exactly same filename. So if I use the action in batch mode for many files, I only get one ai file in the end because it is always overwriting the same file.

 

How can I set a dynamic filename for the export paths to illustrator function?

 

Any ideas?

 

Thanks alot!

TOPICS
Actions and scripting, How to

Views

791

Likes

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 1 Correct Answer

Adobe Community Professional , Apr 14, 2020 Apr 14, 2020
Try this script. It can be recorded as an action step and then used in File > Automate > Batch command. Files must be saved, exported files will be saved in the same folder as the original file using the same variable document name with suffix of "_Paths" and the ".ai" filename extension. Such as: Original Image Name.psd Original Image Name_Paths.ai (this suffix is easy to remove from the script if you don't like it) Downloading and Installing Adobe Scripts // Export All Paths to Illu...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 14, 2020 Apr 14, 2020

Copy link to clipboard

Copied

If you have a problem with an action you want help with  you need to post the Action's  ActionSet.atn file so we can see exactly how he action has been created.  

 

It sound like you are using a save as step and have recorded a file name into the action step.  You should not record a name you should just let Photoshop default to the current  document's name.

JJMack

Likes

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
Adobe Community Professional ,
Apr 15, 2020 Apr 15, 2020

Copy link to clipboard

Copied

Unlike saving a file, exporting the paths always seems to hard-code the same document name:

 

path-export.png

Likes

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
Adobe Community Professional ,
Apr 14, 2020 Apr 14, 2020

Copy link to clipboard

Copied

This is due to how the action records the export, I don't believe that you have any control over this with an action. 

 

It is probably scriptable using exportDocument with ExportOptionsIllustrator and appropriate properties, variables etc.

 

I'll see if I have time to come up with something later.

Likes

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
Adobe Community Professional ,
Apr 14, 2020 Apr 14, 2020

Copy link to clipboard

Copied

Try this script. It can be recorded as an action step and then used in File > Automate > Batch command. Files must be saved, exported files will be saved in the same folder as the original file using the same variable document name with suffix of "_Paths" and the ".ai" filename extension.

 

Such as:

Original Image Name.psd

Original Image Name_Paths.ai

(this suffix is easy to remove from the script if you don't like it)

 

Downloading and Installing Adobe Scripts

 

 

 

// Export All Paths to Illustrator Using Variable Document Name.jsx

#target photoshop

/*
Export all paths to Illustrator format using the current document name
This script is suitable for use in the File > Automate > Batch command
https://community.adobe.com/t5/photoshop/how-to-export-paths-to-ai-in-action-batch/m-p/11049923 
How to export paths to AI in action / batch
*/

/* Start Unsaved Document Error Check - Part A: Try */
unSaved();

function unSaved() {
    try {
        activeDocument.path;
        /* Finish Unsaved Document Error Check - Part A: Try */

        /* Main Code Start */

        /* Based on the following topic thread:
        https://community.adobe.com/t5/photoshop/exporting-all-paths-to-illustrator-error/m-p/8796143 */

        var doc = app.activeDocument;
        var docPath = doc.path;
        var docName = doc.name.replace(/\.[^\.]+$/, '');
        var newFile = File(docPath + '/' + docName + '_Paths' + '.ai');
        var expOptions = new ExportOptionsIllustrator;
        expOptions.path = IllustratorPathType.ALLPATHS;
        doc.exportDocument(newFile, ExportType.ILLUSTRATORPATHS, expOptions);
        // alert('All Photoshop paths have been exported as a single Illustrator file in:' + '\r' + docPath);

        /* Main Code Finish */

        /* Start Unsaved Document Error Check - Part B: Catch */
    } catch (err) {
        alert('An image must be both open and/or saved before running this script!')
    }
}
/* Finish Unsaved Document Error Check - Part B : Catch */

 

 

 

atn-batch.png

Likes

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
New Here ,
Apr 15, 2020 Apr 15, 2020

Copy link to clipboard

Copied

Hey Stephen,

 

your script was exactly what I was looking for and is working like a charm 🙂

 

Thanks a lot!

 

Likes

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
Adobe Community Professional ,
Apr 15, 2020 Apr 15, 2020

Copy link to clipboard

Copied

Glad to be of help and thank you for the courtesy of the reply, like and correct answer!

Likes

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 ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

I am struggling to get this to work. Simply paste into TextEdit, save as a .JS file ... then place file into Scripts folder. But nothing shows up and the script doesn't run. Using Apple Script Editor, the code breaks right away. What am I doing wrong?!

Likes

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
Adobe Community Professional ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

You are assuming that this is AppleScript, when it is JavaScript. EDIT: Also ensure that you are saving as TXT and not RTF.

 

Downloading and Installing Adobe Scripts

 

Likes

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

I’m just a silly graphic designer, not a coder or programmer. Not trying to assume anything, just that this “walkthrough” is not easy to follow.

I copied the code into both TextEdit and Apple Script and … then am lost. Anyone have a video showing step by step?

Likes

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
Adobe Community Professional ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Don't sell yourself short!

 

I don't know of a video, it is really not that hard.

 

(1) Copy the code text to the clipboard

(2) Open a new blank file in a plain-text editor (not word processor)

(3) Paste the code in

(4) Save the text file as .txt

(5) Rename the text .txt to .jsx

(6) Install or browse to the .jsx file to run

(7) If these simple instructions are too abbreviated, you may need to read in more detail the full instructions:

Downloading and Installing Adobe Scripts

 

Forget about AppleScript, the code is JavaScript.

Likes

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
New Here ,
Jul 08, 2021 Jul 08, 2021

Copy link to clipboard

Copied

Hmmm...

followed your directions, also looked at the provided link

 

Question: I've got the .JSX file created

I go into File > Scripts > Script Events Manager

I then Select Enable Events To Run Scripts/Actions.

 

which Event would you recommend choosing/creating?

This is the problematic area it appears.  Please suggest the right Event.  I'll add an event, and I'll use the Event Codes  "Export expr"

I then select Script, and then choose the script (your .JXS file) to run when the about export event occurs.

I then click ADD

 

I then run my Action (which has the export to illlustrator paths in the ATN action)

It keeps rewriting over the initial file name

 

I can understand the previous authors frustration.
Can you check your .JXS code to see if it's correct?

Could you write out all the appropriate Script Events Manager steps?

 

many thanks

Likes

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
Adobe Community Professional ,
Jul 08, 2021 Jul 08, 2021

Copy link to clipboard

Copied

It sounds like you are a little confused...

 

quote

Hmmm...

followed your directions, also looked at the provided link

 

Question: I've got the .JSX file created

I go into File > Scripts > Script Events Manager

I then Select Enable Events To Run Scripts/Actions.

 

which Event would you recommend choosing/creating?

This is the problematic area it appears.  Please suggest the right Event.  I'll add an event, and I'll use the Event Codes  "Export expr"

I then select Script, and then choose the script (your .JXS file) to run when the about export event occurs.

I then click ADD

 

I then run my Action (which has the export to illlustrator paths in the ATN action)

It keeps rewriting over the initial file name

 

I can understand the previous authors frustration.
Can you check your .JXS code to see if it's correct?

Could you write out all the appropriate Script Events Manager steps?

 

many thanks


By @nycprinter

 

Where did I mention using the Scripts Events Manager for this script in this topic thread? I believe that you are the one that brought this up.

 

My original instruction was to record this script into an action. Then use the batch command to play hte action on selected files.

 

Did you pehaps post in the wrong forum topic?

Likes

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
Adobe Community Professional ,
Jul 08, 2021 Jul 08, 2021

Copy link to clipboard

Copied

I just tested and everything works fine.

 

I created/saved two different PSD file. Both had different file names and multiple different path names in each file.

 

Running the JavaScript manually on each open document created a new single .AI per single .PSD, each .AI file had all of the paths that were in the .PSD in the .AI file. Each .AI file had the same name as the source .PSD file with the suffix addition of _Paths added.

 

I then recorded the use of this script into an action.

 

I then ran a batch using the action that referenced this script.

 

2 output .AI files were produced from the 2 input .PSD files.

 

I didn't use Script Events Manager.

Likes

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
New Here ,
Jul 08, 2021 Jul 08, 2021

Copy link to clipboard

Copied

Hi Stephen,

Thanks for helping out, it has been very frustrating

 

Ok, I guess I didn't comprehend that part on making the .JXS file into a action step. 

I read up on how to manual run a JXS script  (file->scripts-> jxs)

 

I realize I needed to have my action record this critical step... just ran the action , and yes, you are correct. Everything worked perfectly.  Sorry for my confusion and thanks for the clarity!

 

 

 

 

 

 

Likes

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
Adobe Community Professional ,
Jul 08, 2021 Jul 08, 2021

Copy link to clipboard

Copied

LATEST

No worries, the script could be altered so that it can perform the batch operation itself, without the hack of recording the script into an action and then batching the action... I just used that hack as it is flexible and quick, without having to write and test more code for the batch processing.

Likes

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