Copy link to clipboard
Copied
Hi All,
Is there any way as opening an Illustrator document as a template / copy?
app.executeMenuCommand('newFromTemplate'); doesn't provide an option to include the file path.
I know I can open a doc as the original and do saveAs but I am not looking for that.
JSX, Applescript or terminal command solutions would all be good but not UI based ones.
Thanks
Trevor
Thanks for your reply.
It's not what I'm after.
moluapple snippet is much closer.
In the end I made a copy of the Ai file (foo.ai) with a different name (foo-not-processed.Ai) and then after saving the final processed file (foo-not-processed.Ai) I rename it to (foo-processed .Ai)
It's not the most resource efficient although not too bad but it's safe and quick.
Regards
Trevor
Copy link to clipboard
Copied
Hi, can you accept this solution ?
var f = File.openDialog ('Select the file...', '*.ai'),
n = f.name;
f.rename (f.name + 't');
app.open(f);
f.rename (n);
Copy link to clipboard
Copied
Thanks for the suggestion. I had thought of it but I'm not excited about it.
The same applies to duplicating the file and renaming it although I think I will end up doing that.
Copy link to clipboard
Copied
This may help you.
#target illustrator
var dialogBox =
"dialog { orientation: 'column', alignChildren: 'center', \
info: Group { orientation: 'column', alignChildren: 'center', \
templateType: Group { orientation: 'column', alignChildren: 'center', margins: 0, \
rbtn1: { text: 'Select the template file', assignmet: 'left'}, \
dividerLine: Panel { preferredSize: [280,1], margins:0,},\
componentsGroup: Group { alignChildren: 'right' , orientation: 'column' ,\
componentList: ListBox {preferredSize: [260,150], left: 100, properties:{multiselect:false} align:'right'}, \
st:StaticText {text:'', preferredSize:[280,0]},\
applySkinTo: Group { orientation: 'row' , alignChildren: 'top',\
},\
},\
}, \
}, \
dividerLine: Panel { preferredSize: [280,1], margins:0,},\
buttons: Group { orientation: 'row', \
ok: Button { text: 'OK', properties:{name:'ok'} }, \
cancel: Button { text: 'Cancel', properties:{name:'cancel'} }, \
} \
}";
win = new Window (dialogBox);
win.text = "Graphics";
var lstbx = win.info.templateType.componentsGroup.componentList;
var templatePath;
var templateComponentPath;
if($.os.substring(0,3)=="Win")
{
templatePath = " "; // Pl. provide the path
templateComponentPath = templatePath + "/template";
}
var templateFolder = new Folder(templateComponentPath);
var files = templateFolder.getFiles();
for (i = 0; i < files.length; ++i)
{
var fileName = files.name;
var index = fileName.lastIndexOf(".ait");
if(index != -1)
{
var onlyFileName = fileName.substring(0,index);
lstbx.add("item",File.decode(onlyFileName));
}
}
win.buttons.ok.onClick = function()
{
var doc1;
if(win.info.templateType.rbtn1.value)
{
var componentPath = templateComponentPath + "/"+ lstbx.selection.text + ".ait";
doc1 = app.open (new File(componentPath));
}
else
{
var componentPath = templateComponentPath + "/"+ lstbx.selection.text + ".ait";
doc1 = app.open (new File(componentPath));
}
win.close(0);
}
win.buttons.cancel.onClick = function()
{
win.close(0);
}
win.center();
win.show();
Copy link to clipboard
Copied
Thanks for your reply.
It's not what I'm after.
moluapple snippet is much closer.
In the end I made a copy of the Ai file (foo.ai) with a different name (foo-not-processed.Ai) and then after saving the final processed file (foo-not-processed.Ai) I rename it to (foo-processed .Ai)
It's not the most resource efficient although not too bad but it's safe and quick.
Regards
Trevor
Copy link to clipboard
Copied
I am wondering, why did you need to do these steps instead of using the simple open -> process > Save-As process?
Copy link to clipboard
Copied
Hi Silly,
I am batch processing PDF files that can contain up to about 200,000 path objects, the object can be sometimes a bit complicated.
The can be sometimes 100s of these files.
My client says all the files are backed up but I would rather avoid touching them to avoid any risk of corrupting them.
If I were to be more of a risk player I could open them and do save as strait away on Ai and then process and save again. 2 X save as like you are thinking, right?
We'll how many extra hours would it take to do the more risky method? I don't know but it certainly would be a lot.
Convinced 😉
Trevor
Copy link to clipboard
Copied
Well I see you had in mind just 1 save as, that's just too risky.
Copy link to clipboard
Copied
See, I was under impression that when you 'open' a file in AI, it actually copies the file inside the application - so unlike other kinds of applications such as Excel, where you can't delete a file that's open in Excel right now, in the file system, you can delete an AI file that's already opened and it won't even complain at you. I also think that is why when you drag a file into the app fame of AI or PS, etc, it will show the tooltip "copy" near the cursor.
Copy link to clipboard
Copied
I don't know, maybe you are correct.