Copy link to clipboard
Copied
i found this very interesting.
in this example sel0 has to be a placed file.
file to execute can be anything you want.
works for windows.
Batchfile for apple?I don't know
![]()
chris
var sel0 = app.activeDocument.selection[0].file;
// function UrltoWin(fi){
// fi = fi.toString();
// fi = fi.replace(/%20/g," "); // %20 -> whitespace
// fi = fi.replace(/\//g,"\\"); // slash -> backslash
// fi = fi.replace(/\\c/,"C:"); // \c -> C:
// // alert(fi)
// return fi
// }
function UrltoWin(fi){
return fi.toString().replace(/%20/g," ").replace(/\//g,"\\").replace(/\\c/,"C:");
}
var tex = "START ";
tex += " \"\" ";
tex += "\"c:\\Programme\\Adobe\\Photoshop 7.0\\Photoshop.exe\"";
tex += " \""+ UrltoWin(sel0) +"\"";
var bat = new File("/c/test.bat");
bat.open("e");
bat.writeln(tex)
bat.execute();
bat.close();
// bat.remove(); // ??? wait ???
bat = null; //???
Copy link to clipboard
Copied
this makes a snapshot with xnview,
name it, and save it to the document dir.
$.sleep(100);
var p = app.activeDocument.path, n = app.activeDocument.name.split(".")[0];
function UrltoWin(fi){
return fi.toString().replace(/%20/g," ").replace(/\//g,"\\").replace(/\\c/,"C:");
}
var tex = "@echo off\ncls\nSTART";
tex += " \"\" ";
tex += "\"c:\\Programme\\xnview\\xnview.exe\" ";
tex += "-capture=active,\"" + UrltoWin(p) + "\\" + n + "Ss#.jpg\"" ;
var bat = new File("~/AiScript.bat");
bat.open("w");
bat.writeln(tex);
bat.close();
bat.execute();
bat = null;
resulting batch:
@echo off
cls
START "" "c:\Programme\xnview\xnview.exe" -capture=active,"C:\tenp\visitenkarte_LP_GG3Ss#.jpg"
how should this look for Mac?
chris
Copy link to clipboard
Copied
Chris, can you not decode the path like so…
var p = decodeURI(app.activeDocument.path);
I know nothing of windows what is it that you are doing here?
Copy link to clipboard
Copied
Hm, Mark, i don't know![]()
what the function does is
/c/my%20files/
to
c:\my files\
if it could be done with decodeurl , great.
i have not tryed it.
edit: no, this "deletes" %20, but do not translate it in windows notation.
if it works on mac, one problem less (?this can't be good english)
Do you know how "batch"files on mac should look?
or do you mean, you don't understand it completly?
ok, xnview is a third party pictureviewer.
bat is a DOS batch file(from Skript created), whitch START xnview, with params: -make snapshot- , and save it as DocNameSs[number].jpg, in DocFolder
Chris
Copy link to clipboard
Copied
It is very likely that your third party app does NOT exist for mac? Your 'bat' files are windows executables 'batch' commands yes? If this the case then these too do NOT exist in the mac environment. You would need to look to a shell/UNIX alternative. These can be used file.execute() with CS3 and above the permissions need to be set correctly for them to be seen as executable on OSX. I only have CS2 so NOT done anything with any of this.
Does do the same on windows?
var p = app.activeDocument.path.fsName; $.writeln(p)
Sorry but Im used to mac style file paths…
Copy link to clipboard
Copied
yes and yes.
but it is only a example for what can be done.
fsName, damn,
, this will do it too.
And is cross-platform. thank you.
good to know too that this not work below cs3.
Chris
Copy link to clipboard
Copied
resurrecting a CRAZY OLD thread here.. Sorry about that. But I'm looking to do something similar right now, but i need to return the results of the file that i'm executing.
Specifically, my shell script is reading a webpage at a specific URL. I need to return that string of text that is being read by the URL request and then parse it back in ESTK.
currently, i'm trying this...
var shell = (path to shell script file);
shell.open();
var result = shell.execute();//this line results in a boolean.
shell.close;
how can i store the returned result of my shell script in a variable so that i can parse it in ESTK?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more