So, after I keep digging, and keep reading, I finally find the getPanelRelativeURL() function (yeah guess I'm blind).
However, documentation states that this will return the following:
Returns a String representing the full path of the relative path with respect to the panel's path.
Example
// If we have a panel stored at C:\Users\Test\Panels\ and we store images in a // directory \Images\
located in the same \Panels\ folder that the panel itself is located in, we can // use the line
ogscript.getPanelRelativeURL('\Images\');
// to get the String "C:\Users\Test\Panels\Images\".
However, no, this does not work.
In the example above, for some reasons they add escape strings in front of the ' for the string sub folder we're looking for.
What you should be using is:
var relPath = ogscript.getPanelRelativeURL('Images/');
However, this will also not give you back the expected string mentioned in the example above. You'll get something similar, but you will also get a "file:/" before the file path itself, like so:
file:/C:\Users\Test\Panels\Images\
This again cannot be used in the getFile() function before. And not to mention if you had a space in the folder names or similar, you will get this returned as URI encoded characters, with %20 for space etc... These cannot be used for the getFile() function either.
So, first thing you do is just to get rid of the file:/ by using the JS slice function. Then follow it up by using a decodeURI on the string as well for good meassure.
var path = file:/C:\Users\Test\Panels\Images\;
path = path.slice(6);
path = decodeURI(path);
Then you'll finally end up with a clean string, formatted in such a way that it can be used for the getFile() function.
Now with the get file function, you can add whatever file name you're looking for, either through a parameter or just a simple string value, concatenate the two, and you can check for whatever file you want.
var file = 'BLANK.png'; // The filename we're looking for.
path = ogscript.getPanelRelativeURL('Images/'); //DB path + subfolder "Images"
path = path.slice(6);
path = decodeURI(path);
path = path + file;
var res = ogscript.getFile(path);
if (res == null) {
ogscript.debug('RESULT: No such file...');
// Do whatever you need if there is no such file...
} else {
ogscript.debug('RESULT: ' + res);
// Do what you want to do when you confirm there is a file there...
}
Hope someone might find this usefull!
#DashBoard