Skip to main content
Known Participant
Jan 8, 2022 11:13 AM UTC
Answered

Bridge script: how to select thumbnail by file name

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 is closed to new replies. Start a new post to keep the conversation going.
Kukurykus
KukurykusCorrect answer
Legend
Jan 8, 2022 1:54 PM UTC

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

 

15 replies

Legend
Jan 10, 2022 3:02 PM UTC

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);
}
Translate
Kukurykus
Legend
Jan 10, 2022 10:16 PM UTC

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

Translate
Kukurykus
KukurykusCorrect answer
Legend
Jan 8, 2022 1:54 PM UTC

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

 

Translate
Rudolf LAuthor
Known Participant
Jan 8, 2022 3:43 PM UTC

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

}

 

Translate
Kukurykus
Legend
Jan 8, 2022 4:12 PM UTC

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

Translate