You are missing a space between the do and the parenthesis
The construct if errorlevel n is evaluated to true for any errorlevel value equal or greater to n, so if errorlevel 0 will be true for any non negative errorlevel value. You should use if not errorlevel 1
It is a good habit to quote all paths just in case something could include a space or a special character
for /R "D:\path\import_orders\xml_files" %%f in (*.xml) do (
copy "%%~ff" "\\destination"
if not errorlevel 1 move "%%~ff" "D:\path\import_orders\xml_files\archive\"
)
To avoid the directory recursion, just change the for loop, removing the /R (that asks for recursion) moving the start folder tip to the file selection pattern.
for %%f in ("D:\path\import_orders\xml_files\*.xml") do (
copy "%%~ff" "\\destination"
if not errorlevel 1 move "%%~ff" "D:\path\import_orders\xml_files\archive\"
)
But in any case copy command does not ask for confirmation if target file exists. If you don't want to overwrite the existing file you have some options
Use the switches of the copy command
You can use /-y so copy command will ask for confirmation before overwritting the file, and to automate the process you can pipe the answer to the question
echo n|copy /-y "source" "target"
This is the approach in the npocmaka's answer. This approach should work without problems but
It is necessary two create two cmd instances to handle each of the sides of the pipe, and to do it for each of the source files, so it will slow the process
It could fail if the code is executed on a locale where the overwrite question is not waiting a N character as a negative answer.
First check for file presence
You can use the builtin if exist construct to first check if the target file is present
if not exist "\\destination\%%~nxf" copy "%%~ff" "\\destination"
where %%~nxf if the name and extension of the file being processed
So, the final code could be
for %%f in ("D:\path\import_orders\xml_files\*.xml") do (
if not exist "\\destination\%%~nxf" copy "%%~ff" "\\destination"
if not errorlevel 1 move "%%~ff" "D:\path\import_orders\xml_files\archive\"
)
if !errorlevel! equ 0 move...copy /y copy "%%~ff" "\\destination"