Revision: 26008
Updated Code
at July 4, 2010 12:34 by karlhorky
Updated Code
:: mirrorp.bat :: Mirror contents of one directory to another with prompt using Robocopy :: :: Usage examples: :: mirrorp C:\source \\server\share\destination :: mirrorp D:\mydirectory "C:\directory name with spaces" :: :: Author: Karl Horky :: Date: 15 April 2010 :: Updated: 03 July 2010 (added /IS /IT /COPYALL to get NTFS permissions and date time tweaks - Thanks Chris) @echo off SETLOCAL if ""%1"" == """" ( goto :error ) if ""%2"" == """" ( goto :error ) SET _source=%1 SET _dest=%2 robocopy %_source% %_dest% /MIR /IS /IT /COPYALL /L echo. echo. set /p ans=Run mirror? [y/n]^> if "%ans%" == "y" ( goto :copytotest ) else ( goto :donothing ) :copytotest echo. echo. echo Copying... robocopy %_source% %_dest% /MIR /IS /IT /COPYALL /NJS /NJH goto :eof :donothing echo No action taken. goto :eof :error echo Incorrect command usage. echo Usage: mirrorp C:\source \\server\share\destination
Revision: 26007
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 15, 2010 17:35 by karlhorky
Initial Code
:: mirrorp.bat :: Mirror contents of one directory to another with prompt using Robocopy :: :: Usage examples: :: mirrorp C:\source \\server\share\destination :: mirrorp D:\mydirectory "C:\directory name with spaces" :: :: Author: Karl Horky :: Date: 15 April 2010 @echo off SETLOCAL if ""%1"" == """" ( goto :error ) if ""%2"" == """" ( goto :error ) SET _source=%1 SET _dest=%2 robocopy %_source% %_dest% /MIR /L echo. echo. set /p ans=Run mirror? [y/n]^> if "%ans%" == "y" ( goto :copytotest ) else ( goto :donothing ) :copytotest echo. echo. echo Copying... robocopy %_source% %_dest% /MIR /NJS /NJH goto :eof :donothing echo No action taken. goto :eof :error echo Incorrect command usage. echo Usage: mirrorp C:\source \\server\share\destination
Initial URL
Initial Description
This batch mirrors the contents of one directory to another using Robocopy. It will display a list of what is being mirrored before prompting the user for confirmation on the mirror. WARNING: Robocopy's /MIR switch that is used in this batch WILL remove any destination objects not present in the source directory
Initial Title
DOS Batch: Mirror Contents of One Directory to Another with Prompt using Robocopy
Initial Tags
directory
Initial Language
DOS Batch