We help IT Professionals succeed at work.

i need to write a script to copy backup data to a netwrok share day per day

Medium Priority
Last Modified: 2012-05-05
hi guys,
i want to write a script that copies data from a specific directory in windows to a directory in a network share.and i want the script run daily(could be dne with task scheduler) but i need the copies to be named as the per the the date that it was taken. i hope i was clear in my request.Does anyone have a sample or template that i can use it have this script.thank to you all
Watch Question


"xcopy c:\data\* f:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S" This is simple Windows Batch file and the task scheduler to create an automated daily backup.
 Save this command in notepad & save as backup.bat file.
 In this the xcopy commands will copy files and folders. The syntax for the command is xcopy [source] [destination] [arguments]. Where source is the folder that you want to backup and destination is the backup on the network drive. The arguments tell xcopy how to handle certain situations. For my script I used /Y to suppress prompting when overwriting files. If you do not include this the script will ask you before copying each file, that wouldnt be automated. /Q doesnt display the file names while copying. /S copies directories and sub directories. You can find more arguments by opening the command windows and typing xcopy /?.
%date:~10,4%_%date:~4,2%_%date:~7,2%_backup will create folder with current date.

kadadi_vIT Admin

Start>run>ntbackup and use the backup wizard as per your requirement daily/weekly & monthly basis.


Vijay kadadi


dear srawale,
i did not get what are the 4,2%...and all the percentages .any way it did not work, it gave me anneror so i had to remove them.can u send it again please??
hi Sparks

Rename this file as .txt to .bat  change folder name as your requirment.



when i run the script :xcopy c:\dell\* d:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S

it gave me this message:
Invalid switch - /_00_backup\*


xcopy c:\dell\* d:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S

In this script all data of c:\dell folder will copied to d:\backup folder with current year_current month_current date_backup folder in short script will create the destination folder as d:\backup\2008_02_06_backup.

  You cross check the command again. as per my eariler attachment.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.