Copy link to clipboard
Copied
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!!!
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hi, извините, я не говорю по России, добро пожаловать на форум,
you're missing a slash (/) at the beginning, this should fix the problem
var tmpFolder = '/c/media_files/vector/vector_tmp';
Copy link to clipboard
Copied
Thanks big for the help, all have turned out.
Small annoying error, and how many tortures!
Once again thanks!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now