Here's my code:
@echo off
echo ->minus
echo _>underscore
rem if this file is used it tries to execute a command
echo not-at-all>'notacomand'
echo processing two files at once
for /f "delims=" %%# in (minus underscore ) do echo %%#
echo processing file and command
for /f "delims=" %%# in (minus '"echo ++"') do echo %%#
echo processing files and string
for /f "delims=" %%# in (minus underscore "zzz") do echo %%#
rem searches for file "zzz" minus
rem for /f "delims=" %%# in ("zzz" minus) do echo %%#
rem searches for file zzz" minus
rem for /f "delims=" %%# in ("zzz" minus) do echo %%#
echo the command at the end is not processed
for /f "delims=" %%# in (minus "zzz" 'echo ---') do echo %%#
rem searches for file 'echo
rem for /f "delims=" %%# in (minus 'echo ---' "zzz") do echo %%#
Tested on Windows 8.1 and Windows XP. ]:-).
I've tested very few combinations but my conclusions so far are:
- You can process as many files as you want at once.Wild cards are not
accepted.For files with spaces
useback
should be used. - You can process as many files as you want at once puls ONE command (but with additional double quotes) or string.Everything after the string or command will be ignored except syntax errors.
Have no idea why (most probably without the cmd code answer is impossible).Also have no idea if this can be useful or is known behavior , but definitely is curious.