Silent error while trying to execute a batch convert-to-binary
I'm attempting to write a BASH function to allow me to batch convert an entire project to jsxbin. The batch script works when i run it directly in extendscript, but when i attempt to run it from the command line it simply fails silently.
in my BASH function, i'm using the following (among several other things that seem to be working just fine):
compileScript="~/Desktop/compile_file.jsx"
/Volumes/Macintosh\ HD/Applications/Adobe\ ExtendScript\ Toolkit\ CC/ExtendScript\ Toolkit.app/Contents/MacOs/ExtendScript\ Toolkit -cmd "$compileScript"
the -cmd call to ETSK executes, but does not actually appear to execute the $compileScript compiler, as no files are saved when it's complete. It doesn't throw any errors, it simply doesn't do anything. Again, the same compile_file.jsx script works flawlessly when i run it from ESTK.
Here's the compile_file.jsx code:
function compileBinary()
{
#target estoolkit#dbg
// var batchFolder = new Folder("/Volumes/Macintosh HD/Users/will.dowling/Desktop/").selectDlg("Select a folder to batch.");
var batchFolder = new Folder("/Volumes/Macintosh HD/Users/will.dowling/Desktop/convert_to_binary");
var destFolder = new Folder("/Volumes/Macintosh HD/Users/will.dowling/Desktop/binary_converted");
var files = batchFolder.getFiles();
var contents,compiled,outFile;
var pat = /\s/g;
var extPat = /\.js
?/; var newExt = ".jsxbin";
for(var x=0,len=files.length;x<len;x++)
{
if(files
.name.indexOf(".js") === -1) {
continue;
}
files
.open("r"); contents = files
.read(); files
.close(); compiled = app.compile(contents);
compiled = compiled.replace(pat,"");
compiled = "eval(\"" + compiled + "\")";
if(files
.name.indexOf(".jsx")>-1) {
outFile = new File(destFolder + "/" + files
.name) }
else
{
outFile = new File(destFolder + "/" + files
.name + "xbin" ); }
outFile.open("w");
outFile.write(compiled);
outFile.close();
}
}
compileBinary();
Any thoughts on this? It seems that i've followed the example in the scripting reference, but it doesn't seem to work.
