Hi All:
I have a javascript that creates new files on windows and mac. On the windows side it creates a file name ok and calls it B5177-123-My style.ai
on the mac side the same exact script pulled from same location creates a file name that on the Mac looks similar except it includes the last folder name I told it to store in so if desktop it will store it one folder level up and call it desktop\B5177-123-My style.ai but if I copy it to our mutual win/mac server the file name shows up as D23458A~.ai
Any help would be greatly appreciated. Script is included if that helps. I bolded the section that is most likely causing the problem.
THanks,
Ron
#target illustrator
// for this code to work it must have 12 items in each row seperated by tabs.
// items are order#,custcd,customer name, style-colour, style desc,colour,emb type, placement,unused,unused,style file name including path,comments, embcode
// 0 1 2 3 4 5 6 7 8 9 10 11 12
function testBtnOnClick() {
// this.parent.buildBtn.enabled = true;
//this.parent.make1Btn.enabled = true;
var dlg = this.parent.parent;
var mydata = calculateApprovalsVG(this.parent.parent.msgEt.text);
//var data = showdata(mydata);
//var data = mydata;
// debugger;
//dlg.dataStore = mydata;
//dlg.CADLoc = parseCADLoc(dlg.msgCAD.text);
//fillList(dlg, data);
}
// pick folder for saving completed forms
// what is this? looks same as routine above
function main() {
var thisC = this;
this.dlg = new Window('dialog', 'Paste document data below');
this.dlg.dataStore = new Array();
this.dlg.CADLoc = new Array();
this.dlg.size = {width: 1000, height: 570};
this.dlg.msgEt = this.dlg.add('edittext', undefined, '', {multiline:true});
this. dlg.msgEt.size = {width: 970, height: 500};
//this.dlg.msgCAD = this.dlg.add('edittext', undefined, '<CAD Location Data>', {multiline:true});
//this. dlg.msgCAD.size = {width: 970, height: 100};
//this. dlg.msgCAD.alignment = 'left';
//this.dlg.listBox = this.dlg.add('listbox', undefined, 'formListBox', {multiselect:true});
//this.dlg.listBox.alignment = 'right';
//this.dlg.listBox.size = {width: 970, height: 200};
//this.dlg.listBox.alignChildren = 'top';
//this.dlg.listBox.formItems = new Array();
this.dlg.btnPnl = this.dlg.add('panel', undefined, );
this.dlg.btnPnl.orientation = 'row';
this.dlg.btnPnl.alignment = 'right';
this.dlg.btnPnl.testBtn = this.dlg.btnPnl.add('button', undefined, 'Make All Forms')
//this.dlg.btnPnl.buildBtn = this.dlg.btnPnl.add('button', undefined, 'Make All Forms');
//this.dlg.btnPnl.buildBtn.enabled = false;
//'this.dlg.btnPnl.make1Btn = this.dlg.btnPnl.add('button', undefined, 'Make Selected Forms');
//'this.dlg.btnPnl.make1Btn.enabled = false;
//'this.dlg.btnPnl.make1Btn.onClick = make1BtnBtnOnClick;
this.dlg.btnPnl.cnclBtn = this.dlg.btnPnl.add('button', undefined, 'Done', {name:'cancel'});
this.dlg.btnPnl.testBtn.onClick = testBtnOnClick;
//this.dlg.btnPnl.buildBtn.onClick = buildBtnOnClick;
this.dlg.show();
}
// Saves the current document to dest as an AI file with specified options,
// dest specifies the full path and file name of the new file
function exportFileToAI (dest, docRef) {
if ( app.documents.length > 0 ) {
var saveOptions = new IllustratorSaveOptions();
var aiDoc = new File(dest);
saveOptions.compatibility = Compatibility.ILLUSTRATOR15;
saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
docRef.saveAs( aiDoc, saveOptions );
}
}
//
//
//
// * validate the data and unless errors proceed now!
//
//
function calculateApprovalsVG(spreadsheet) {
//var spreadsheet = document.barcodegen.spreadsheet.value;
var spreadsheetRows = spreadsheet.split("\n");
var columnArray = new Array();
var xx = 0;
var mydata = new Array();
var m = 0;
// Iterate over the rows and break them down into their columns
var spreadsheetRowsCols = new Array();
//var firstsize = 0;
//var isItSize;
for (var i in spreadsheetRows) {
spreadsheetRowsCols[i] = new Array();
spreadsheetRowsCols[i] = spreadsheetRows[i].split("\t");
xx = spreadsheetRowsCols[i].length
if(spreadsheetRowsCols[i].length<11){
alert("Row "+ i + " must be 12 tabbed items in the list for this to work. Last good order was " +spreadsheetRowsCols[i-1][0],"Big problemo! On strike til you fix this!");
return;
}
// if (spreadsheetRowsCols[i][9].exists){
// alert("File not found "+spreadsheetRowsCols[i][9] +" aborting!");
// }
}
//
// lets try and place the whole thing in here and make it use first array!
//
var destFolder = null;
destFolder = Folder.selectDialog( 'Please select the folder to save the forms to.', '~' );
alert( destFolder );
var tempFile = null;
tempFile = File.openDialog( 'Please choose the template file.', '*.ai' );
if(tempFile) {
var theTemplate = tempFile.fsName;
for(var i in spreadsheetRows) {
if(spreadsheetRows[i] ){
//alert(i + ': ' + mainframe.dataStore[i]['client'] + ' - ' + mainframe.dataStore[i]['style']);
var theStyle = spreadsheetRowsCols[i][3];
var theCAD = spreadsheetRowsCols[i][9];
//alert(theStyle + ': ' + theCAD);
var notset;
if(theCAD == notset) theCAD = '';
makeSingleForm(spreadsheetRowsCols[i], destFolder, tempFile, theCAD);
}
}
}
alert("Processing Complete","All files were created!");
}
function makeSingleForm(artformData, destFolder, theTemplate, theCAD) {
//alert(artformData[i]['scs']);
// File Name
// Point Text
//alert(theTemplate);
var docRef = open(theTemplate);
// Client y: 595 from bottom, 63
var pointTextClient = docRef.textFrames.add();
pointTextClient.contents = artformData[2];
pointTextClient.top = -65;
pointTextClient.left = 550;
pointTextClient.selected = false;
// Licensor Name
var pointTextStyle = docRef.textFrames.add();
pointTextStyle.contents = artformData[8]; // this needs to be fixed or dropped
pointTextStyle.top = -80;
pointTextStyle.left = 550;
pointTextStyle.selected = false;
// Order #
var pointTextStyle = docRef.textFrames.add();
pointTextStyle.contents = artformData[0]; // this needs to be fixed or dropped
pointTextStyle.top = -100;
pointTextStyle.left = 115;
pointTextStyle.selected = false;
// application - artwork code descriptions
var pointTextStyle = docRef.textFrames.add();
pointTextStyle.contents = artformData[6];
pointTextStyle.top = -163;
pointTextStyle.left = 96;
pointTextStyle.selected = false;
// artwork code EMB Code
var pointTextStyle = docRef.textFrames.add();
pointTextStyle.contents = artformData[11];
pointTextStyle.top = -65;
pointTextStyle.left = 116;
pointTextStyle.selected = false;
// Comments
var pointTextStyle = docRef.textFrames.add();
pointTextStyle.contents = artformData[10];
pointTextStyle.top = -125;
pointTextStyle.left = 60;
pointTextStyle.selected = false;
// Placement
var pointTextStyle = docRef.textFrames.add();
pointTextStyle.contents = artformData[7];
pointTextStyle.top = -150;
pointTextStyle.left = 95;
pointTextStyle.selected = false;
// Garment: Style / Colour / Size Breakdown
var pointTextStyle = docRef.textFrames.add();
pointTextStyle.contents = artformData[3]+" "+artformData[4] +" "+artformData[5];
pointTextStyle.top = -80;
pointTextStyle.left = 116;
//pointTextStyle.width = 100;
//pointTextStyle.height = 40;
pointTextStyle.selected = false;
// Product colour
//var pointTextColor = docRef.textFrames.add();
//pointTextColor.contents = artformData[5];
//pointTextColor.top = 95;
//pointTextColor.left = 203;
//pointTextColor.selected = false;
/*
var pointTextBreakdown = docRef.textFrames.add();
pointTextBreakdown.contents = artformData['scs']['breakdown'];
pointTextBreakdown.top = 453;
pointTextBreakdown.left = 311;
pointTextBreakdown.selected = false;
redraw();
*/
if (theCAD != '') {
//alert(theCAD);
// if (theCAD.exists){
var cadRef = open(File(theCAD));
doc=activeDocument;
for (i=0; i<doc.layers.length; i++){doc.layers[i].hasSelectedArtwork=true;} // select all
copy();//
doc.close( SaveOptions.DONOTSAVECHANGES );
docRef.layers.add();
docRef.activeLayer = docRef.layers.getByName("Layer 2");
paste(); //
// end original code
//}else{
//alert(theCAD+" File can't be located for "+artformData[0] );
//return
//}
}
var dest = destFolder + "\\" + artformData[1] + '-' + artformData[3] + '.ai';
//alert(dest);
exportFileToAI (dest, docRef) ;
docRef.close( SaveOptions.DONOTSAVECHANGES );
}
var mainframe = new main();