There is a hard way of getting filename only from a path. Or extension from a path. And there is a sweet n’ simple way to do it.
The trick is to separate your code in another batch file and call it with parameters. In that batch file you can use for example %~n1 to get filename only of passed path.
Why I needed that? Well, that’s a very good question indeed….