Remember:
- Replace double precentages with single precentage if you want to use it in CMD directly.
- When file names are printed out, they already include double quotes.
@echo off
echo - - - Print the file names of all files in folder (with extension - relative path)
for %%A IN (*) DO (echo "%%~nxA")
echo. & echo.
echo - - - Print the file names of all files in folder (without extension - relative path)
for %%A IN (*) DO (echo "%%~nA")
echo. & echo.
echo - - - Print the file names of all files in folder (with extension - absolute path)
for %%A IN (*) DO (echo "%%~dpnxA")
echo. & echo.
echo - - - Print the file names of all files in folder (without extension - absolute path)
for %%A IN (*) DO (echo "%%~dpnA")
Example result:
- - - Print the file names of all files in folder (with extension - relative path)
"A beautiful picture.png"
"A movie file.mkv"
"An archive file.zip"
"Some text file.txt"
"test2.bat"
- - - Print the file names of all files in folder (without extension - relative path)
"A beautiful picture"
"A movie file"
"An archive file"
"Some text file"
"test2"
- - - Print the file names of all files in folder (with extension - absolute path)
"C:\example\A beautiful picture.png"
"C:\example\A movie file.mkv"
"C:\example\An archive file.zip"
"C:\example\Some text file.txt"
"C:\example\test2.bat"
- - - Print the file names of all files in folder (without extension - absolute path)
"C:\example\A beautiful picture"
"C:\example\A movie file"
"C:\example\An archive file"
"C:\example\Some text file"
"C:\example\test2"