if exist do not copy on bat script

see bat script below - i want to make sure that when the script runs if the file exists it just go to end and if the file does not exist then execute
does this look right


@echo off  
setlocal
set userdir=%localappdata%\Microsoft\Office
set remotedir=\\domain.com\netlogon\Deployments\CustomOfficeRibbon
if not exist "%userdir%\Excel.officeUI" copy "%remotedir%\Excel.officeUI" "%userdir%\Excel.officeUI"
rem pause
endlocal
LVL 2
IT GuyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
Looks good. It works here. Your code copies only if %userdir%\Excel.officeUI does not exist.

Per your question "... if the file exists it just go to end", it should be:
@echo off  
setlocal
set userdir=c:\local\test
set remotedir=\\domain.com\netlogon\Deployments\CustomOfficeRibbon
if exist "%userdir%\Excel.officeUI" goto :eof
copy "%remotedir%\Excel.officeUI" "%userdir%\Excel.officeUI"
rem pause
endlocal 

Open in new window


But either way works.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
.. true, but if all you want to do is the copy, stay with your code. Goto is so 80s.
BTW, if you do not want to change the file name on copy, just provide the target (folder) path. That usually makes your script easier to change later.
Bill PrewIT / Software Engineering ConsultantCommented:
And just so you know, keep in mind that BAT scripts have a basic IF ... THEN ... ELSE syntax as well, so you can do things like:

@echo off  
setlocal

set userdir=%localappdata%\Microsoft\Office
set remotedir=\\domain.com\netlogon\Deployments\CustomOfficeRibbon

if not exist "%userdir%\Excel.officeUI" (
    copy "%remotedir%\Excel.officeUI" "%userdir%\Excel.officeUI"
) else (
    echo INFO: File "%userdir%\Excel.officeUI" already exists, not copied.
)

rem pause
endlocal

Open in new window

~bp
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.