Skip to main content
Known Participant
January 8, 2022
Answered

Bridge script: how to select thumbnail by file name

  • January 8, 2022
  • 2 replies
  • 1826 views

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.

This topic has been closed for replies.
Correct answer Kukurykus

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')))

 

2 replies

Brainiac
January 10, 2022

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);
}
Kukurykus
Brainiac
January 10, 2022

That's code I wanted to suggest if the requested method failed. Use false to resign from canceling a task.

Kukurykus
KukurykusCorrect answer
Brainiac
January 8, 2022

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')))

 

Rudolf LAuthor
Known Participant
January 8, 2022

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()

}

 

Kukurykus
Brainiac
January 8, 2022

What do you run first, .bat (by extendscript) or my code? Say step by step...