FOR /R %%i return 一些奇怪的事情

FOR /R %%i return some strange things

pushd %~dp0
set actdir=%cd%
mkdir "%cd%\numbers"
SET count=1
for /R %%i in ("C:\Users\me\Desktop\bt") do (call :subroutine %%i %~xi)
GOTO :eof

尝试递归地从一个文件夹(以及子目录)中获取所有文件,copy/rename将它们转移到不同的路径。

%%i 正在返回一些非常非常奇怪的东西。确切地说,这个:

C:\Users\me\Documents\RunningBatchFolder\"C:\Users\me\Desktop\bt"

所以就像两条组合路径。 怎么会?请问如何解决?

再加上一个问题,%~xi报错:The following usage of the path operator in batch-parameter substitution is invalid: %~xi

这样试试:

for /R "C:\Users\me\Desktop\bt" %%i in (*) do (call :subroutine %%i %~xi)

还有更多info

    Unlike some other variants of the FOR command you must include a wildcard 
   (either * or ?) in the 'set' to get consistent results returned. In many    cases
    you can work around this by adding a single character wildcard e.g. if you 
    are looping through multiple folders to find the exact filename myfile.txt 
    you could instead specify myfile.t?t