Salir
  • Comunidad global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Saving to a Relative Subfolder

Explorador ,
May 03, 2018 May 03, 2018

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.

TEMAS
Scripts
1.7K
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines

correct answers 1 respuesta correcta

Comprometido , May 04, 2018 May 04, 2018

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 + "/"

...
Traducir
Adobe
Community Expert ,
May 03, 2018 May 03, 2018

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Explorador ,
May 03, 2018 May 03, 2018

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?

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
May 03, 2018 May 03, 2018

If you have a file named Test.ai in folder D:\Z-Test\TopFolder1\Subfolder1\Subfolder2\Subfolder3

PfadZurDatei.png

… 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.

PfadeZurSpeichern.png

That's all.

Have fun

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 04, 2018 May 04, 2018

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Comprometido ,
May 04, 2018 May 04, 2018

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Explorador ,
May 04, 2018 May 04, 2018

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Principiante de comunidad ,
Mar 31, 2021 Mar 31, 2021

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!

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Mar 31, 2021 Mar 31, 2021
MÁS RECIENTES

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines