Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Automated copy and paste batch job using DOS batch file?

Options
  • 14-12-2013 12:06pm
    #1
    Closed Accounts Posts: 131 ✭✭


    I have a backup folder location where backups are stored. I need to copy the backup files to a NAS drive folder every day. Would a DOS batch file run using Windows task scheduler do this?

    Is there any other way to do this?

    Would you please post the code for doing this here.

    Any help greatly appreciated.


Comments

  • Registered Users Posts: 7,157 ✭✭✭srsly78




  • Registered Users Posts: 434 ✭✭TheBoffin


    Create a batch file with the following code and edit to taste.
    I always recommend using the /log switch in case of problems.

    robocopy x:\sourcefolder y:\destinationfolder /log:batchlog.txt

    Obviously test your batch file on a non critical folder set, e.g. create folders and copy some files in to test


  • Closed Accounts Posts: 131 ✭✭net4hack


    Thanks. Is there any way to delete the source files after the copy process has been completed. The backup files are about 10GB.


  • Closed Accounts Posts: 131 ✭✭net4hack


    Also I need to rename each backup file with the date of the backup.


  • Registered Users Posts: 434 ✭✭TheBoffin


    Try the following

    robocopy x:\source y:\%date% /mov

    This produces a file structure of y:\date\month\year\....files so you would need to clear the destination directory each month


  • Advertisement
  • Closed Accounts Posts: 131 ✭✭net4hack


    The every day backup files need to be moved to a folder with that days date. I used the following command

    set mydate=%date:~6,4%%date:~3,2%%date:~0,2%

    robocopy "C:\Users\admin\Desktop\test" "C:\Users\admin\Desktop\%mydate%" /move /E /log:batchlog.txt

    So idealy this should create a folder like 20131216 and move the directories and files to this folder. But this doesnt happen if I include the set date command. See attached picture. If I run the second command alone it works fine. So is there any way I could run both command in a batch file.


Advertisement