Batch File to Copy and Move files and Folders from one place to another

Here is an example of a BATCH file that can run be run manually or scheduled in Task Scheduler that will Copy of files and folders to a new location on a 2nd server or NEW FOLDER on the Same server.  Just change the _dest variable.  Simply plug in your OWN servername and folder path and run the batch file.  Please NOTE this is a very dangerous batch file and it will delete all files and folders under its path!

:: This program copies all files in the OLD FILES FOLDER on S: :: and copies it to NEW FILES FOLDER on SERVER2

@ECHO OFF SETLOCAL

SET _source=\\SERVER\SHARE\OLD FILES

SET _dest=\\SERVER2\SHARE\NEW FILES

SET _what=/MOV /MIR

 

:: /COPYALL :: COPY ALL file info

:: /B :: copy files in Backup mode.

:: /E :: copy Subfolders including Empty.

:: /MIR :: MIRror a directory tree

:: /MOVE :: Move files and dirs (delete from source after copying).

:: /MOV :: MOVe files (delete from source after copying).

 

SET _options=/R:0 /W:0 /LOG:MyLogfile.txt /NFL /NDL

:: /R:n :: number of Retries

:: /W:n :: Wait time between retries

:: /LOG :: Output log file

:: /NFL :: No file logging

:: /NDL :: No dir logging

 

ECHO ********************************************************************

ECHO ***** THIS WILL DELETE ALL FILES IN OLD FILES on SHARED DRIVE

ECHO ***** TO THE NEW FILES FOLDER ON SERVER2 -CLOSE OUT NOW WITH X on WINDOW TO STOP THIS

ECHO ***** OR FILES WILL  BE DELETED.

TIMEOUT /T 20

ROBOCOPY %_source% %_dest% %_what% %_options%