'XCOPY Folder with Variable Name and Spaces

I want to create a batch that deletes files from some folders and then copies them back into them from another destination (another server). Some of these folders will have variable names because they are named based on the month and the year. For example one of the destinations contains folders named like these :

-01 January 2015
-02 February 2015
-03 March 2015
etc.

I've managed to make the delete process work, but when it's time to copy I get this error :

xcopy is not recognized as an internal or external command, operable program or batch file.

Here is the code :

    echo off
    for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
    set "YYYY=%dt:~0,4%"
    set "MM=%dt:~4,2%"
    set "DD=%dt:~6,2%"
    set "HH=%dt:~8,2%"
    set "Min=%dt:~10,2%"
    set "Sec=%dt:~12,2%"
    set "YY=%dt:~2,2%"
    
    if %MM%==01 set Month=January
    if %MM%==02 set Month=February
    if %MM%==03 set Month=March
    if %MM%==04 set Month=April
    if %MM%==05 set Month=May
    if %MM%==06 set Month=June
    if %MM%==07 set Month=July
    if %MM%==08 set Month=August
    if %MM%==09 set Month=September
    if %MM%==10 set Month=October
    if %MM%==11 set Month=November
    if %MM%==12 set Month=December
    
    
    set path=-%MM% %Month% 20%YY%
    
    del /f/s/q "P:\WX\%path%\Today"
    
    xcopy "F:\WX\%path%\Today" . "P:\WX\%path%\Today" /s/e/y
      


Solution 1:[1]

I believe it is due to the set path=-%MM% %Month% 20%YY%:

PATH is an environment variable, which contains the location of all commands that you might need to start from a random location, hence it is advised never to modify this variable. Just replace it by path2 and you'll fall into another problem :-)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dominique