Windows BAT

一个BAT拷贝程序:

:: For example: SRC_PATH = C:\hello\world
:: and DEST_PATH = E:\another
:: this program will first delete contents of  DEST_PATH from the disk, then copy contents of SRC_PATH to DEST_PATH
:: make sure this file is encoded with the default encoding of the environment to support internationalization

@ECHO OFF

set SRC_PATH=F:\baiduyundownload\miniGame\.minecraft\saves
set DEST_PATH=F:\TEMP\MC

rmdir /s /q %DEST_PATH%

md %DEST_PATH%

xcopy /s /y %SRC_PATH% %DEST_PATH%

pause

 

 

Q:如何创建文件夹?

A:

md %PATH_NAME%

 

Q: 如何查看命令的帮助?

A:

以xcopy为例,输入xcopy /?即可

 

Q: 如何使用注释?

A:

::是单行注释的开头,类似C++里的//

 

Q: 如何拷贝文件夹(及其子文件夹)?

A:

xcopy /s /y %SRC_PATH% %DEST_PATH%

 

Q: 如何删除文件夹(及其子文件夹)?

A:

rmdir /s /q %FOLDER_NAME%

 

Q: 如何使用变量?

A:

:: 需要注意的是=号前后不能有空格

@ECHO OFF

SET my_var=helloworld

ECHO %my_var%

posted @ 2015-03-29 01:44  rldts  阅读(205)  评论(0编辑  收藏  举报