How can I edit this so it works with files that have spaces?
@echo off
set /A Counter=0
setlocal enabledelayedexpansion
for %%D in ("e:\test test\") do (
for /f %%F in ('dir /a-d /b %%D*.*') do (
开发者_JS百科 ECHO.
ECHO Current file is: %%F
set src=%%F
set dest="e:\test test\space locate\%%F"
if not exist !dest! move !src! !dest!
if exist !dest! (
ECHO.
ECHO ERROR: "%%F" already exists
set /A Counter+=1
)
ECHO source file is !src!
ECHO destination is !dest!
)
)
echo.
echo %Counter% files not moved.
You probably just need to put quotes ("
) around all your filenames.
I'm talking about this sort of thing:
if not exist "!dest!" move "!src!" "!dest!"
That's just a suggestion, I don't have time to actually try to debug it right now.
Edit in response to comment:
for
by default uses spaces as delimiters. You should say for /f "delims="
instead of just for /f
in order to tell it not to do that.
精彩评论