Check and alert user if files exists

How can I check in a button if a file/exe exists! and alert the user if it doesn't?

Can I output to the script log from buttons? I'm trying to use the dialogstring to output a message for now, is there an alert like JavaScript?

// Here you can customize the mp3val path (it handles alias)
@set exe={alias|dopusdata}Scripts\mp3val.exe
@ifexists:{exe}
@if:else
@runonce:@set target={dlgstringS|mp3Val not found:|Click Ok}

You can use @confirm to display a simple OK/Cancel prompt from a non-script button.

Using a script button is the way to go if you want to do anything more complex than that.

Thanks!

As for the code above, is it correct? It doesn't seem to work, and I can't test in the CLI, only in buttons.

See my questions in the comments in the code below

// get the mp3val files here https://sourceforge.net/projects/mp3val/files/latest/download?source=files
// and put it in /dopusdata\scripts directory
// Here you can customize the mp3val path (it handles alias)
@set exe=/dopusdata\Scripts\mp3val.exe
//this doesn't work, the popup will show exactly the same thing "{$exe}", i guess no variable evaluation in dialogs? However {file} works.
@confirm:"{$exe}" 
// the following doesn't work at all, how to get it to work? Does exist automatically evaluate the paths? or needs a realpath?
// Check if the executable exists before running
@ifexists:{$exe}
@confirm:mp3Val found! \nPlease fix the path in the button and try again
@if:else
@confirm:mp3Val not found! \nPlease fix the path in the button and try again

// Show a log only if it exists! 
// This also doesn't work! What is the scope of @if statement? all following statements or only 1 after? Or is it the variable evaluation?
@ifexists:{filepath|..\}mp3Fix.log
notepad.exe {filepath|..\}mp3Fix.log

You should break the problem down to work out where the issue is.

Use full paths, don't use aliases, and don't use variables. Start from there and see if it works. If it does, add one thing at a time and re-test.

I got it to work using the alias. Currently the button works for me, but I was trying to see if I could make it easier for other users, by putting in some error checking.

I think the problem is with my @if commands
I found this post that explained the issue, that @ifexists doesn't work with variables.

see this excerpt

But the alias option doesn't work either. Anyway I've decided to ignore it for now. as it works for me for now.