Robocopy - As an automated batch file.

Soldato
Joined
12 Jun 2012
Posts
3,918
Location
West Yorkshire
Hi guys

So i am running this robocopy cmd line:

robocopy.exe \\sourceservernameA\directory \\source_server_nameB\directory /E /SEC /COPYALL /V /ETA /TEE /ITEM

Which works good and fine. Although is there a way that i could set this up as a little .bat file were it keeps the settings up i can change the \\servernames\directories when it asks me? so every time its double clicked, it will ask me for the Source and target to be keyed in?

Thinking of sharing it so others can use it.

If not any decent freeware that will do this?

Thanks.
 
Last edited:
The SET /P command may be of use. You could even store default directories to avoid typing in the same ones repeatedly?
 
Not tested but should be good for a starting point at least:

@Echo off
Title Robocopy
:start
Echo Robocopy
echo.
:choice
echo Choice: 1 = Run Robocopy
echo.
echo Choice: 0 = Exit
echo.
set choice=
set /p choice=Select a choice:
Echo.
if '%choice%'=='1' goto :choice1
if '%choice%'=='0' goto :choice0
echo.
echo "%choice%" is Not a valid entry Please try again.
ping 127.0.0.1 -n 2 >nul
echo.
goto choice

:choice1

:start
setlocal
set /p Target=Please enter the Host Path:
set /p Target2=Please enter the Target Path:
robocopy.exe \\%Target% \\%target2% /E /SEC /COPYALL /V /ETA /TEE /ITEM
endlocal

Goto start

:choice0
Exit
 
Last edited:
Being prompted to manually type in the full source and target paths each time seems a bit of a clumsy way of doing things - there's plenty of room for things to go pear-shaped if you make a typo for example.

Wouldn't something like FreeFileSync be a simpler solution?
 
Not tested but should be good for a starting point at least:

@echo off
Title Robocopy
:start
Echo Robocopy
echo.
:choice
echo Choice: 1 = Run Robocopy
echo.
echo Choice: 0 = Exit
echo.
set choice=
set /p choice=Select a choice:
Echo.
if '%choice%'=='1' goto :choice1
if '%choice%'=='0' goto :choice0
echo.
echo "%choice%" is Not a valid entry Please try again.
ping 127.0.0.1 -n 2 >nul
echo.
goto choice

:choice1

:start
setlocal
set /p Target=Please enter the Host Path:
set /p Target2=Please enter the Target Path:
robocopy.exe \\%Target% \\%target2% /E /SEC /COPYALL /V /ETA /TEE /ITEM
endlocal

Goto start

:choice0
Exit

This works! Thanks you very much!!

Being prompted to manually type in the full source and target paths each time seems a bit of a clumsy way of doing things - there's plenty of room for things to go pear-shaped if you make a typo for example.

Wouldn't something like FreeFileSync be a simpler solution?

Yeah i know things could go wrong but it will only be for IT use, its not rocket science for them to type the path in.

FreeFilesync is like xsync file synchronizer by the looks of it? Will check this out, thanks.
 
FreeFilesync is like xsync file synchronizer by the looks of it? Will check this out, thanks.
I'm not familiar with that one, but I guess they all do the same basic thing. :)

Don't forget to check out the FreeFileSync help file, there's a fair bit of functionality that isn't obvious from a quick look at the GUI.
 
Back
Top Bottom