Not in SQL, no ... I suspect you picked the wrong language tag!
It's certainly possible, but exactly how would depend on the language / framework you are using.
For example, in C#, it's one line of code:
string paths = Directory.GetFiles(rootPath, "*.jpg", SearchOption.AllDirectories);
The array then contains each JPG file complete with it's full path as separate strings.
In other languages it may be more complex, but it depends on your skill set, which we have no idea about!