views:

43

answers:

1
@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 (
            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.
+1  A: 

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.

Blorgbeard
`dest` has quotes already ... you only need to put them around `src` here. Still, +1 as it should be the solution.
Joey
When I tried that it still isn't taking in files that have a space in them :(http://pastebin.com/m1e766aa2
Matt