for /r %%i in (*) do (echo %%i)
Results in
%%i was unexpected at this time
Why?
for /r %%i in (*) do (echo %%i)
Results in
%%i was unexpected at this time
Why?
You must be trying to run the command from the command line and not from within a batch file. Use a single % instead of two when running from the command line.
for /r %i in (*) do (echo %i)
Type HELP FOR
from the command line and read the 3rd paragraph.
If Anyone is wondering how to extract the data to a file
using CMD
All files
for /r %i in (*) do @echo %~ni >> AllFiles.txt
For a specific extension
for /r %i in (*.mp3) do @echo %~ni >> songs.txt
File name with extension
for /r %a in (*) do @echo %~nxa >> FileNameWithExtension.txt
Note: If you're making a batch script use "%%" instead of every "%" mentioned above
Syntax:
FOR /R [[drive:]path] %%parameter IN (set) DO command
Need the path before %%i... which is why it's Unexpected
If you want to do *
for current directory, just use ".\" for the path
for /r ".\" %%i in (*) do (echo %%i)