I have written a bash script that gets three paths based on input parameters and then then gets the imagename/filename in the path.
Something like: I provide:
$PATH is a predefined variable which gives the directories to search when looking for executables. Pick a different variable name for your script and you'll be fine.
$PATH