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!
1 Correct answer
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
...
Explore related tutorials & articles
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.
Copy link to clipboard
Copied
Unlike saving a file, exporting the paths always seems to hard-code the same document name:
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.
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 */
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!
Copy link to clipboard
Copied
Glad to be of help and thank you for the courtesy of the reply, like and correct answer!
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?!
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
Copy link to clipboard
Copied
I copied the code into both TextEdit and Apple Script and … then am lost. Anyone have a video showing step by step?
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.
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
Copy link to clipboard
Copied
It sounds like you are a little confused...
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?
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.
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I'm using Illustrator 2020 and there is no File > Automate > Batch menu. instead I try File > Scripts > Other Script and import your code (saved as .jsx file). Then I get a msgbox alert "An image must be both open and/or saved before running this script!" (which I have opened my ai files already.)
I run the same file in Apple Script Editor using javascript and get the same result. what did I do wrong?
Copy link to clipboard
Copied
This is not an Illustrator script, it is a JavaScript for Photoshop. The clue is here:
#target photoshop
By itself, the script will save the vector paths of the file open in Photoshop . It can also be run on a batch of raster files to save out the vector paths for multiple files (if the script is recorded into an action and run as a batch action).
So what you are doing wrong is using it in Illustrator, which does not have the same menus, nor does it use the same DOM code as the script is for Photoshop.
Copy link to clipboard
Copied
I forgot to mention, I need to export .ai into .png inside Adobe Illustrator 2020. I guess if there is a script setting in PS then there might be the same setting existed in AI too.
Copy link to clipboard
Copied
You are in the wrong forum, should post in the Adobe Illustrator forum:
https://community.adobe.com/t5/illustrator/ct-p/ct-illustrator
Copy link to clipboard
Copied
will do. thanks!

