Publish folders to Web sites after batch backup folders and files _dos/bat

Source: Internet
Author: User
Tags goto
First, under the "C:\ Web site" corresponding "D:\ Project 1" Under All folders and files back to the "D:\ backup 2012-9-1-52647", and then "D:\ Project 1" published to the "C:\ site."
usage
Backupandpublish.bat "D:\ Project 1"
Copy Code code as follows:

@echo off
Set sourcedir=%1
Set now=%date:~0,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%%time:~3,2%%time:~6,2%
:: Parameter
Set destdir= "C:\ Web Site"
Set backdir= "D:\ backup%now%"
Echo.
Echo is backing up
Call:backup%sourcedir%%destdir%%backdir%
Echo.
Echo is releasing
Call:publish%sourcedir%%destdir%
Goto:eof
:: Main Program
: Backup
Setlocal enabledelayedexpansion
Set Sourcedir=%~1
Set destdir=%~2
Set Backdir=%~3
:: Calculating Source path length
Set sourcedirlen=0
Set sourcedirstr=%sourcedir%
: Next1
If not "%sourcedirstr%" = "" (
set/a sourcedirlen+=1
Set "sourcedirstr=%sourcedirstr:~1%"
Goto:next1
)
:: Backup
FOR/R "%sourcedir%"%%i in (*.*) do (
Set backpath=%%~dpi
Set backpath=%backdir%! backpath:~%sourcedirlen%!
Set destpath=%%i
Set destpath=%destdir%! destpath:~%sourcedirlen%!
Set backfilepath=%%i
Set backfilepath=%backdir%! backfilepath:~%sourcedirlen%!
Echo! destpath!
xcopy! " destpath! " "! backpath! "/r/y >nul 2>nul
If not exist! " backfilepath! " (Echo Backup replication failed)
)
FOR/R "%sourcedir%"%%i in (\) do (
Set sourcepath=%%i
Set sourcepath=! sourcepath:~0,-1!
Set backpath=%backdir%! sourcepath:~%sourcedirlen%!
MD "! backpath! ">nul 2>nul
)
Setlocal disabledelayedexpansion
Goto:eof
:: Publish
:P ublish
Set sourcedir=%1
Set destdir=%2
xcopy%sourcedir%%destdir%/r/y/i/e
Goto:eof

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.