i have problem in this code
xcopy works fine but when add ELSE dont work
why that?
@echo off & setLocal EnableDELAYedeXpansion
for /f "tokens=* delims= " %%a in ('dir /s /b/a-d "c:\windows\temp2\"') do (
if not exist "c:\windows\temp\%%~nxa" xcopy "%%~pnxa" "c:\windows\temp\
goto bb
ELSE (GOTO start1)
)
:bb
echo no need to copy
ping -n 5 localhost> nul
exit
:start1
echo finish copy
ping -n 10 localhost> nul
exit
thanks in advance.
What is wrong in this code ????
Moderator: DosItHelp
Re: What is wrong in this code ????
'
Untested !
This is just a little better, it can be much better, this way you'll understand though.
You made several mistakes like forgetting to add a quote, telling CMD to close the DOS session with exit instead of closing only the function etc..
try this:
Untested !
Code: Select all
@echo off & setLocal EnableDELAYedeXpansion
for /f "tokens=* delims= " %%a in (
'dir /s /b/a-d "c:\windows\temp2\"'
) do if not exist "c:\windows\temp\%%~nxa" (
::
xcopy "%%~pnxa" "c:\windows\temp\"
goto :bb "()"
) ELSE GOTO :start1 "()"
:bb ()
::(
echo.no need to copy
ping -n 5 localhost> nul
::)
exit /b 0
:start1 ()
::(
echo.finish copy
ping -n 10 localhost> nul
::)
exit /b 0
You made several mistakes like forgetting to add a quote, telling CMD to close the DOS session with exit instead of closing only the function etc..
try this:
Code: Select all
@echo off
call /? |more
exit /? |more
for /? |more
if /? |more
Re: What is wrong in this code ????
Thank u for your great reply
but still alittle problem
the purpose of this code to compare two folders
but when i add new file or more the code do not copy them and move to :start1 () although there is differnt between two folders
thanks
but still alittle problem
the purpose of this code to compare two folders
but when i add new file or more the code do not copy them and move to :start1 () although there is differnt between two folders
thanks