It seems you do not properly understand what you read when you do research. As an example.
For /r %%i in (.) do ( echo %%~nf >>list1.txt
tells me you have seen this %%~nf
somewhere but did you try read up on what it does? You give a variable of %%i
but you try and use %%f
and you want the path (%%~p
) but use the name (%%~n
). If you actually ran the help from cmd for /?
you would have had some great tips.
This:
For /r %%i in (*.jpg) do echo "%%~dpi" >>list1.txt
Would give drive and path to file, where this:
For /r %%i in (*.jpg) do echo "%%~pi" >>list1.txt
Would give just the path, while this:
For /r %%i in (*.jpg) do echo "%%~nxi" >>list1.txt
Would give the name and extention of the file and finally this:
For /r %%i in (*.jgp) do echo "%%~ni" >>list1.txt
Would give only the name of the file without extension.
So I challenge you to run help switches for your commands via cmd and I promise you, you will be astonished to see what you can learn from this.