Page 1 of 1
Illegal filepath. Miss ")". Why?
Posted: Wed Nov 06, 2019 1:29 pm
by klevteev
Hello!
I used a script to save a file on a certain path C:\Users\abcde\Desktop\temp, with adding unique numbers(think do texts through dialog box), until'm hammering manually each time.
So the script worked-worked... and then stopped, to speak omitted symbol of ")", although all is true. What's wrong?
Code: Select all
var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.MM;
var docRef = app.activeDocument;
filePath = docRef.path;
var fileName = docRef.name.slice(".")
var W = Math.round(docRef.width);
var H = Math.round(docRef.height);
function SaveAsTIFF( saveAsName ) {
var tso = new TiffSaveOptions();
tso.embedColorProfile = false;
tso.imageCompression = TIFFEncoding.NONE;
tso.byteOrder = ByteOrder.IBM;
docRef.saveAs( File( saveAsName ), tso );
}
SaveAsTIFF ( C:\Users\abcde\Desktop\temp + ("001_" + W +"x" + H + "mm_" + fileName));
docRef.close(SaveOptions.DONOTSAVECHANGES); //Fermer sans sauver
app.preferences.rulerUnits = strtRulerUnits;
Re: Illegal filepath. Miss ")". Why?
Posted: Fri Nov 08, 2019 1:26 pm
by Kukurykus
Re: Illegal filepath. Miss ")". Why?
Posted: Fri Nov 08, 2019 1:40 pm
by Scriptor
Hi!
Try this - I've commented the changes I've done.
Code: Select all
var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.MM;
var docRef = app.activeDocument;
filePath = docRef.path;
//var fileName = docRef.name.slice(".")
var fileName = docRef.name.replace(/\.[^\.]+$/, ''); //Removes weird stuff and file extensions
var W = Math.round(docRef.width);
var H = Math.round(docRef.height);
function SaveAsTIFF( saveAsName ) {
var tso = new TiffSaveOptions();
tso.embedColorProfile = false; //Note: Color profile is quite handy to include
tso.imageCompression = TIFFEncoding.NONE;
tso.byteOrder = ByteOrder.IBM;
docRef.saveAs( File( saveAsName ), tso );
}
var tiffpath = new Folder("file:///c://Users//abcde//Desktop//temp"); //Sets directive to save image in
var tiffname = "001_" + W +"x" + H + "mm_" + fileName; //Sets name of image
var fullpath = File(tiffpath + "/" + tiffname + '.tif'); //Combines path+name
SaveAsTIFF (fullpath);
docRef.close(SaveOptions.DONOTSAVECHANGES); //Fermer sans sauver
app.preferences.rulerUnits = strtRulerUnits;
Re: Illegal filepath. Miss ")". Why?
Posted: Fri Nov 08, 2019 2:04 pm
by Scriptor
Kukurykus wrote: ↑Fri Nov 08, 2019 1:26 pm
should be:
Hands down - this is a more elegant solution
Re: Illegal filepath. Miss ")". Why?
Posted: Fri Nov 08, 2019 3:11 pm
by Kukurykus
Let's see which answer klevteev will choose
Re: Illegal filepath. Miss ")". Why?
Posted: Mon Nov 11, 2019 2:44 pm
by klevteev
Re: Illegal filepath. Miss ")". Why?
Posted: Tue Nov 12, 2019 5:17 pm
by Kukurykus
The question is why did not you use " (closing quotation mark) after temp word in in the path?
Re: Illegal filepath. Miss ")". Why?
Posted: Wed Nov 13, 2019 1:29 pm
by klevteev
Kukurykus wrote: ↑Tue Nov 12, 2019 5:17 pm
The question is why did not you use " (closing quotation mark) after
temp word in in the path?
O my god! it`s work!!))) Thank`s a lot!!!
I didn't understand why - ), and I had to look - "
a little upgrade script: to enter the assigned number through the dialog box
But - new topic? or can suggest the right syntax
Code: Select all
var N = parseFloat (dlg.msgPnl.N.et.text);
But - numeric value, how do text?
All Script:
Code: Select all
var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.MM;
var docRef = app.activeDocument;
filePath = docRef.path;
var fileName = docRef.name.slice(".")
var dlg = new Window('dialog', 'Number:');
dlg.frameLocation = [200, 200];
dlg.msgPnl = dlg.add('panel', undefined, 'Parametres');
dlg.msgPnl.alignChildren = "right";
dlg.msgPnl.N = dlg.msgPnl.add('group');
dlg.msgPnl.msgHeight = dlg.msgPnl.add('group');
dlg.msgPnl.selectFolder = dlg.msgPnl.add('group');
with (dlg.msgPnl) {
N.st = N.add('statictext', undefined, 'Number:');
N.et = N.add('edittext', undefined, '027');
N.et.preferredSize = [80,20];
};
var bolUserCancel = false;
dlg.buttons2 = dlg.add('group');
dlg.buttons2.btnClose = dlg.buttons2.add("button",undefined , "Ok" );
dlg.buttons2.btnClose.onClick = function() { this.parent.close(0); };
dlg.buttons2.btnCancel = dlg.buttons2.add("button",undefined , "Cancel" );
dlg.buttons2.btnCancel.onClick = function() { bolUserCancel = true; this.parent.close(0); };
dlg.show();
var N = parseFloat (dlg.msgPnl.N.et.text);
delete dlg;
var W = Math.round(docRef.width);
var H = Math.round(docRef.height);
function SaveAsTIFF( saveAsName ) {
var tso = new TiffSaveOptions();
tso.embedColorProfile = false;
tso.imageCompression = TIFFEncoding.NONE;
tso.byteOrder = ByteOrder.IBM;
docRef.saveAs( File( saveAsName ), tso );
}
SaveAsTIFF ("C://Users//klevteev//Desktop//temp//" + (N + W +"x" + H + "mm_" + fileName));
app.preferences.rulerUnits = strtRulerUnits;
Re: Illegal filepath. Miss ")". Why?
Posted: Wed Nov 13, 2019 1:39 pm
by klevteev
Sorry!
sorted)
dlg.msgPnl.N.et.text - works
Re: Illegal filepath. Miss ")". Why?
Posted: Wed Nov 13, 2019 4:09 pm
by Kukurykus