@ Echo offset sourcr_path = D: \ 1 Set dd = % Date :~, 10% set TT = % time :~, 8% echo % DD % TT % set target_path = D: \ % DD % echo % target_path % if exist % sourcr_path % (the echo directory to be copied is D: \ 1) if not exist % sourcr_path % (echo Directory D: \ 1 to be copied does not exist goto end) if exist % target_path % (RD/Q/S % target_path % echo % target_path % already exists, to copy it, delete it) if not exist % target_path % (mkdir % target_path % echo % target_path % created successfully) xcopy % sourcr_path % target_path %/S/eecho backup successful: endpause
Print:
2012-07-17 17:09:35
D: \ 2012-07-17
The directory to be copied is D: \ 1.
D: \ 2012-07-17 already exists. to copy it, delete it successfully
D: \ 2012-07-17 created successfully
D: \ 1 \ 10.txt
D: \ 1 \ 11 \ 11.txt
Two files are copied.
Backup successful
Press any key to continue...