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

Save the file multiple times

New Here ,
Feb 07, 2011 Feb 07, 2011

I am sorry for my English!

Illustrator CS5

It is necessary for me to keep an AI-file some times in certain folders, plus to keep and EPS.
The first preservation goes normally, that is I open a file and I start a script, the file remains on the specified way and with the name changed by me.

The code of the first saving:

------------------------------------------------------------------------------------

      var currentMainDoc = app.activeDocument;
      var currentDoc = app.activeDocument.name;
      var fullPath = app.activeDocument.path;
      // We decode a way of the active document and it is replaced it with the necessary
      var fullNewPath = Folder.decode(fullPath);
      fullNewPath = fullNewPath.replace(drawFolder,expandFolder);

      // We check directory existence on a new way if isn't present, we create it
      var newFolderExpand = new Folder(fullNewPath);
           if (!newFolderExpand.exists) { newFolderExpand.create();    }
      // We collect new file name on a new way with adding to suffix file name _exp and we create a file
      var currentNewDoc = currentDoc;
      currentNewDoc = fullNewPath+"/"+currentNewDoc.replace(".ai","_"+sfx_exp+".ai  ");
      var newDocExp = new File(currentNewDoc);
      // We form saving options
      var saveExpOptions = new IllustratorSaveOptions();
      saveExpOptions.compatibility = Compatibility.ILLUSTRATOR15;
      // We save a file under a new name
      app.activeDocument.saveAs(newDocExp,saveExpOptions  );

------------------------------------------------------------------------------------

After that I try to save already new active file in EPS (Options of saving EPS I do not write that there is less than code):

------------------------------------------------------------------------------------

     var currentEps10Doc = currentMainDoc.name;
      // We collect new file name on a new way with adding to suffix file name _e10 and we create a file
      currentEps10Doc = tmpFolder+"/"+currentEps10Doc.replace("_exp.ai","_"+sfx_e10+".  eps");
      var newDocEps10 = new File(currentEps10Doc);
      // We save a file under a new name
      var  saveEps10Opts = getEps10Options();
      currentMainDoc.saveAs(newDocEps10, saveEps10Opts);

------------------------------------------------------------------------------------

Doesn't save, because at creation var newDocEps10 = new File (currentEps10Doc); permanently in the beginning the way is added
/c/Program%20Files/Adobe/Adobe%20Illustrator%20CS5/Support%20Files/Contents/Windows/,

that is the full path turns out:

/c/Program%20Files/Adobe/Adobe%20Illustrator%20CS5/Support%20Files/Contents/Windows/c/media_files/vector/vector_tmp/primer_e10.eps

The most interesting that at creation var newDocEps10 = new File (); the following also turns out:

/c/Program%20Files/Adobe/Adobe%20Illustrator%20CS5/Support%20Files/Contents/Windows/tmp00000002

And if it is necessary to address to any file and you create var aaa = File (SomeFile); the first way always is present at the beginning.

How to solve a problem?

Thanks!!!

TOPICS
Scripting
1.3K
Translate
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 Expert ,
Feb 08, 2011 Feb 08, 2011

Hi, it works ok here (with a few modifications).

Do you have the variable "tmpFolder" defined somewhere else? or you're trying to save the EPS in the default temporary folder?.

In Windows 7 the default temp folder is here C:\Users\carlos\AppData\Local\Temp

what's your first language?

var currentMainDoc = app.activeDocument;

      var currentDoc = app.activeDocument.name;

      var fullPath = app.activeDocument.path;

      // We decode a way of the active document and it is replaced it with the necessary

      var fullNewPath = Folder.decode(fullPath);

      fullNewPath = fullNewPath.replace("drawFolder","expandFolder"); // I created these folders myself

      // We check directory existence on a new way if isn't present, we create it

      var newFolderExpand = new Folder(fullNewPath);

           if (!newFolderExpand.exists) { newFolderExpand.create();    }

      // We collect new file name on a new way with adding to suffix file name _exp and we create a file

      var currentNewDoc = currentDoc;

      currentNewDoc = fullNewPath+"/"+currentNewDoc.replace(".ai","_"+"sfx_exp"+".ai  ");

      var newDocExp = new File(currentNewDoc);

      // We form saving options

      var saveExpOptions = new IllustratorSaveOptions();

      saveExpOptions.compatibility = Compatibility.ILLUSTRATOR14;

      // We save a file under a new name

      app.activeDocument.saveAs(newDocExp,saveExpOptions  );

      

       /*

---------------------------------------------------------------------- --------------

//After that I try to save already new active file in EPS (Options of saving EPS I do not write that there is less than code):

---------------------------------------------------------------------- --------------

*/

     tmpFolder = Folder.temp; //fullNewPath; // I added this line

      var currentEps10Doc = currentMainDoc.name;

      // We collect new file name on a new way with adding to suffix file name _e10 and we create a file

      currentEps10Doc = tmpFolder+"/"+currentEps10Doc.replace("_exp.ai","_"+"sfx_e10"+".eps");

      var newDocEps10 = new File(currentEps10Doc);

      // We save a file under a new name

      var  saveEps10Opts = new EPSSaveOptions(); // getEps10Options();

       currentMainDoc.saveAs(newDocEps10, saveEps10Opts);

Translate
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 ,
Feb 09, 2011 Feb 09, 2011

Good afternoon!

I speak Russian.

Variable tmpFolder = ' c/media_files/vector/vector_tmp'

The script should save file EPS, then file EPS 10, then file JPG in this folder, and further already there will be an algorithm of the assembly of these files in archive ZIP and the further mailing.

Translate
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 09, 2011 Feb 09, 2011

Hi, извините, я не говорю по России, добро пожаловать на форум,

you're missing a slash (/) at the beginning, this should fix the problem

var tmpFolder = '/c/media_files/vector/vector_tmp';
Translate
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 ,
Feb 16, 2011 Feb 16, 2011
LATEST

Thanks big for the help, all have turned out.
Small annoying error, and how many tortures!
Once again thanks!!!

Translate
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