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}
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
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.