Copy link to clipboard
Copied
Hey there,
maybe i'm too blind to see it. I need something like this pseudo snippet
select(fileName)
but did not find anything like that in the SDK docs.
Background is that i`m running single image files through scripts and when the resulting image returns i want to do further scripting on it, but the original file is still selected.
1 Correct answer
Use it when you are in Bridge on the location with a file to be selected:
with(app.document) deselectAll(), select(new Thumbnail(File('/d/someFile.jpg')))
Copy link to clipboard
Copied
Use it when you are in Bridge on the location with a file to be selected:
with(app.document) deselectAll(), select(new Thumbnail(File('/d/someFile.jpg')))
Copy link to clipboard
Copied
Thank you so much! Of course it works fine in the context i have given you.
But i directly ran into another problem i can't find a solution for.
I'm running a temporary .bat file on the image. What means it's executed in a synchronous way and still working while extendscript is already finished. Means, the .bat needs around 10 seconds and your example code won't find the resulting file. I tried to capture stdout from the bat file for working with callbacks but had no luck. Scratching my head about how to solve that. Maybe you know something?
This is the code is use for generating the batch file:
function runCMD(cmd) {
var f = new File(Folder.temp.fsName + "/temp.bat");
f.open("w");
f.writeln(cmd);
f.close();
f.execute()
}
Copy link to clipboard
Copied
What do you run first, .bat (by extendscript) or my code? Say step by step...
Copy link to clipboard
Copied
First i run the batch script and then i run your code. Then your script deselects, around 5 seconds later the resulting file appears in Bridge.
Copy link to clipboard
Copied
So .bat file executes at its end the .jsx script which selects only 1 file with 5 seconds delay? I guess the 5 seconds delay is because .bat file process takes 5 seconds before run .jsx script?
Copy link to clipboard
Copied
Yes exactly. That's why i'm trying to find a way to let jsx recognize when the bat is finished.
I tried with eventlister "create". I thought when the file is created that would trigger that event, but it didn't. And i tried to somehow get a result from the bat that i could make use of for a callback function. But i don't know enough about shell script. I read every cmd exe would stdout. So i tried various methods to read stdout in jsx but i miserably failed.
Copy link to clipboard
Copied
If you run .bat before .jsx why don't you execute .jsx at last command of .bat script?
Copy link to clipboard
Copied
Is that even possible? How would i do that?
Copy link to clipboard
Copied
jsx.jsx:
#target bridge
alert('Hello!')
bat.bat:
"C:\Program Files\Adobe\Adobe Bridge 2022\Bridge.exe" "D:\jsx.jsx"
Copy link to clipboard
Copied
Aaah! I tried with
Wscript.exe "C:\Users\Public\Blah\blah.jsx"
But now i got the problem that it prompts a warning for executing bridge script (Win11).
Is there a way to suppress that?
Copy link to clipboard
Copied
With a .bat you don't have a warning.
Copy link to clipboard
Copied
I indeed do have a warning.
Just to make clear. Your code does not work for me:
"C:\Program Files\Adobe\Adobe Bridge 2022\Bridge.exe" "D:\jsx.jsx"
what does work, but prompts the warning is:
D:\jsx.jsx
Please note the missing quotes. I'm not sure about the syntax here, but i tried every possible way and the second snippet works (with warning)
Copy link to clipboard
Copied
Quotation marks are significant for paths with spaces. Is your latest Br path the same as mine, and did you try with same named .jsx file on D drive? What about targeting Bridge from .jsx script, did you use it?
Additionally in front of .bat file code you can use following part to close .bat once ran:
start ""
Copy link to clipboard
Copied
You can also use Windows Scripting Host to run Powershell scripts, these are more powerful generally than .bat files. And in Extendscript you use a timed task to check for the file and when it meets your condition, then continue with the processing.
var foo = app.scheduleTask('bar()', 500, true);
bar = function(){
//do stuff
app.cancelTask(foo);
}
Copy link to clipboard
Copied
That's code I wanted to suggest if the requested method failed. Use false to resign from canceling a task.

