cmd项目文件提取封装

cmd项目文件提取打包

@echo off

rem 执行格式:项目文件处理.bat 项目路径 压缩文件名

rem 设置文件路径及压缩文件名
set nowdate=%date:~0,10%

rem 项目路径
set sourceFilePath=%1

rem 压缩文件名,一般为项目名称
set fileName=%2

rem 存放目录,项目名称下按日期分类
set targetFilePath=f:\%fileName%\%nowdate%

rem copy file.
if not exist %sourceFilePath% (
@echo 源文件路径不存在,退出
goto exit
)

if not exist %targetFilePath% (
@echo 创建文件目标目录
  md %targetFilePath%
)

@echo 复制开始
xcopy /e/q/y %sourceFilePath% %targetFilePath%
if errorlevel 1 echo 文件拷贝失败
if errorlevel 0 echo 成功拷贝文件
@echo 复制结束


@echo 处理文件开始
if not exist %targetFilePath% (
@echo 目标目录不存在,退出
goto exit
)
cd %targetFilePath%

@echo 删除不需要文件
rd /s/q bin
rd /s/q src
rd /s/q .settings

for /r . %%f in (.) do (
if exist "%%f\.svn" (
 rd /s/q "%%f\.svn"
 )
)

del /s/q *.log
del /s/q log\*.*
del /s/q data\*.*
del /s/q .classpath
del /s/q .project
del /s/q build.xml
@echo 处理文件完成

@echo 压缩文件

c:
cd C:\Program Files\WinRAR
WinRAR.exe a -k -r -s -m1 -ep1 %targetFilePath%\%fileName%.rar  %targetFilePath%\
@echo 压缩完成

:exit