木子屋 Dnawo's BLOG

使用批处理复制文件并写入日志

👤 dnawo 📅 2008-04-24 👁 6921 👍 0 💬 0 🔄 来源:本站原创
公司服务器上资源存放规则为resid/uid/resid_allfile.rar,其中resid为资源编号,uid为用户编号,同一个resid文件夹存在多个不同uid的子文件夹,但rar的命名都是一样的,例如:1/1009/1_allfile.rar、1/1010/1_allfile.rar、1/1011/1_allfile.rar,现在要求将某一用户的所有资源全部复制出来打包,由于resid非常多,手工效率可想而知,便写了个批处理来解决问题:

@echo off

rem xcopy.bat
rem By:dnawo www.mzwu.com
rem Date:2008-04-24
rem Use:xcopy.bat uid maxresid

echo xcopy begin!wait...

rem write to log
set filename=log.log
echo -------------------------------------------- >>%filename%
(date /t && time /t) >>%filename%
echo uid:%1 >>%filename%

rem copy files
set filepath=c:\Jar\
md %1
for /l %%i in (1,1,%2) do (
	if exist %filepath%%%i\%1\%%i_allfile.rar (
		copy %filepath%%%i\%1\%%i_allfile.rar %1\%%i_allfile.rar
	)
)

set filepath=
set filename=

echo xcopy end!

使用示例:xcopy.bat 10009 5000
参数说明:10009为用户编号,5000为最大的资源编号

@echo off

rem xcopy.bat
rem By:dnawo www.mzwu.com
rem Date:2008-04-24

echo xcopy begin!

set /p uid="请输入用户编号:"
set /p resid="请输入最大的资源编号:"
if "%uid%"=="" set uid=00000
if "%resid%"=="" set resid=0
echo wait...

rem write to log
set filename=log.log
echo -------------------------------------------- >>%filename%
(date /t && time /t) >>%filename%
echo uid:%uid% >>%filename%

rem copy files
set filepath=c:\jar\
md %uid%
for /l %%i in (1,1,%resid%) do (
	if exist %filepath%%%i\%uid%\%%i_allfile.rar (
		copy %filepath%%%i\%uid%\%%i_allfile.rar %uid%\%%i_allfile.rar
	)
)

set filename=
set filepath=
set uid=
set resid=

echo xcopy end!

使用说明:双击xcopy.bat运行批处理文件,输入用户编号和最大资源编号即可!

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 Dos中的变量 下一篇 → 使用控制台WinRAR压缩文件