File name variables in Windows batch
If you need to manipulate (rename, move, etc) files in a windows batch, here are useful variables that can help with that:
set "filename=C:\Temp\Filename.txt"
For %%A in ("%filename%") do (
echo full path: %%~fA
echo directory: %%~dA
echo path: %%~pA
echo file name only: %%~nA
echo extension only: %%~xA
echo expanded path with short names: %%~sA
echo attributes: %%~aA
echo date and time: %%~tA
echo size: %%~zA
echo drive + path: %%~dpA
echo name.ext: %%~nxA
echo full path + short name: %%~fsA