the only command where i found filename extraction was inside a "for". it looks a bit confusing, but does what you want.
put this line inside a xxx.bat file:
Code:
for /F %%I in ("%CD%") do dir /B /O *.txt > %%~nI.m3u
if you do it that way you can simply drag 'n drop a dir on your batch script. no need to copy anything.
Code:
for /F %%I in ("%1") do dir /B /O %1 > %1\%%~nI.m3u