Copy link to clipboard
Copied
Currently working on a script while saves variations of a file for me. Problem I'm having is that I can't get it to save the new files anywhere except the same directory as the original file. I need it to save in specific subfolders but nothing I've tried is working
Currently the code looks more or less like this (large chunks omitted to save reading):
var pdfOption1 = 'Print pdf'; // <--- in here put the name of your PDF settings for EPSON
var pdfOption2 = 'Print pdf'; // <--- in here put the name of your PDF settings for printing
var pdfOption3 = '[Illustrator Default]'; // <--- in here put the name of your PDF settings for ICUT
var pdfFolder1 = 'epson/';
var pdfFolder2 = 'print%20file/';
var pdfFolder3 = 'icut/';
var pdfSuff1 = '_e.pdf'; // Suffix for EPSON PDF
var pdfSuff2 = '_print.pdf'; // Suffix print PDF
var pdfSuff3 = '_icut.pdf'; // Suffix ICUT PDF
function saveCopyAsPDF (setPDF, placePDF, namePDF) {
var doc = app.activeDocument;
var options = new PDFSaveOptions ();
options.pDFPreset = setPDF;
options.viewAfterSaving = false;
var targetFile = null;
targetFile = app.activeDocument.fullName.toString().replace(".ai", namePDF);
doc.saveAs (new File (placePDF + targetFile), options);
doc.close ();
}
saveCopyAsPDF(pdfOption1, pdfFolder1, pdfSuff1);
What I think is supposed to happen is it should save the file as "originalfilename_e.pdf" and place it in the epson folder (which already exists). What happens though is that illustrator simply brings up an empty save as dialogbox. What am I doing wrong in trying to place these pdfs in a subfolder? When naming the pdfFolder variables I have tried '../epson/' '/epson/' and 'epson/' but nothing is working to save to a subfolder relative to the original.
...var doc = app.activeDocument;
var original_file = doc.fullName;
var home = original_file.parent; // here we get the full path to the directory containing your AI file
var export_folder = home + "/myfolder"; // there we want to create a subfolder
var sub_export_folder = new Folder (export_folder + "/mysubfolder"); // and another subfolder beneath the one above
function saveCopyAsAI (place, nameAI) {
var doc = app.activeDocument;
var packaged_file = null;
packaged_file = File (place + "/"
Copy link to clipboard
Copied
If the folder really is present - set the Folder by his path:
var pdfFolder1 = Folder("/d/TopFolder/SubFolder1/epson");
You aslo can get an relative Folder by his parent:
alert (app.activeDocument.path.parent);
Have fun
Copy link to clipboard
Copied
The first one looks like you're telling me to give a complete path, which I can't do. This script will be run in many different folders so it's imperative that I either be able to retrieve the path every time it runs, or just start off by ignoring the root folders.
I'm not certain how I should use the second one, can you show me how to use that in the context of my code?
Copy link to clipboard
Copied
If you have a file named Test.ai in folder D:\Z-Test\TopFolder1\Subfolder1\Subfolder2\Subfolder3
… you can get the path to its folder and parent folder and so on. Now you only have to create a new Folder Object for saving your file at the new location.
That's all.
Have fun
Copy link to clipboard
Copied
var doc = app.activeDocument;
var original_file = doc.fullName;
var home = original_file.parent; // here we get the full path to the directory containing your AI file
var export_folder = home + "/myfolder"; // there we want to create a subfolder
var sub_export_folder = new Folder (export_folder + "/mysubfolder"); // and another subfolder beneath the one above
function saveCopyAsAI (place, nameAI) {
var doc = app.activeDocument;
var packaged_file = null;
packaged_file = File (place + "/" + nameAI);
var save_options = new IllustratorSaveOptions();
save_options.embedICCProfile = false;
save_options.pdfCompatible = false
doc.saveAs (packaged_file, save_options);
doc.close ();
app.open (File (original_file));
}
if (assets_folder.exists || assets_folder.create()); // here we create the new folders if they don't already exist
saveCopyAsAI (export_folder, "export_1.ai");
saveCopyAsAI (sub_export_folder, "export_2.ai");
This snippet just puts a new folder inside the folder containing your AI file, saves the AI with a new name, creates a second subfolder beneath the first one, and saves another copy of your AI.
Copy link to clipboard
Copied
In fact I would have put it inside the code I did to your request in Help Automating Batch
But you opened a new thread. So now you have to merge the scripts and snippets to your needs.
Copy link to clipboard
Copied
Sorry q3player, I didn't want to keep nagging you to complete my code for me on the original question. I'll take this as a learning experience, figure out how this code works, and place it into the existing script myself. Thanks again.
Copy link to clipboard
Copied
Sorry to bother you...but do you know if there's a way someone could help me with this (see link)? I am trying to autosave the resulting files from a script in Photoshop to the subfolders within the main folder from which each set of images was used to make the final file...
https://community.adobe.com/t5/photoshop/saving-contact-sheets-to-subfolders/m-p/11933524#M526172
Thank you for any and all help!
Copy link to clipboard
Copied
this is the illustrator scripting forum.
for photoshop help, you can check here:
https://community.adobe.com/t5/photoshop/bd-p/photoshop?page=1&sort=latest_replies&filter=all