Board logo

标题: [文件操作] 请帮忙看看这段代码 [打印本页]

作者: wangze78    时间: 2011-5-10 14:44     标题: 请帮忙看看这段代码

编写了如下内容:
ECHO **** READ IP

for /f "tokens=15" %%i in ('ipconfig ^| find /i "ip address"') do set ip=%%i

@ECHO OFF&setlocal enableDelayedExpansion   

set   file=%date:~0,4%%date:~5,2%%date:~8,2%

set   name=%date:~0,4%%date:~5,2%

set   d=%date%

set   t=%time:~0,-3%

echo *****     network

if exist S: net use S: /d /y > NUL:

if exist T: net use T: /d /y > NUL:

net use S: \\192.168.113.240\transfer_record  "manta" /user:"mantauser"

IF ERRORLEVEL 1 goto errormsg

net use T: \\192.168.113.240\epat_data  "manta" /user:"mantauser"

IF ERRORLEVEL 1 goto errormsg


if exist C:\ETT\ecelltest08 set equip=ecelltest08&goto Ecell08

exit

:ecell08

2>nul (for %%a in (d:\正常代码\*.*) do if "%%~xa"==""  set a=%%a&md T:\testcell\ecelltest08\正常代码\!a:~0,5!&copy "%%a" T:\testcell\ecelltest08\正常代码\!a:~0,5!)
xcopy D:\正常代码\*.* d:\backup\%name%\正常代码\ /s /y

rem xcopy D:\故障码\*.* T:\testcell\ecelltest08\%name%\ /s /y

IF ERRORLEVEL 1 goto end

rem erase D:\正常代码\ /s /f /q


echo %d% %t% ***%equip% IP:%IP%***  ecelltest08_dataupdate is finish!   >>S:\ecelltest08.log

goto end

运行结果是:T:\testcell\ecelltest08\正常代码 目录下未建立成功文件夹,归档文件拷贝不成功,但是拷贝到d盘的backup没问题;
为什么啊?
作者: wangze78    时间: 2011-5-10 15:45

感谢大家的帮助,我自己搞定了:
2>nul (for /f "delims=" %%a in ('dir D:\正常代码 /a:-d /b') do if "%%~xa"=="" set a=%%a&md T:\testcell\ecelltest08\正常代码\!a:~0,5!&copy d:\正常代码\"%%a" T:\testcell\ecelltest08\正常代码\!a:~0,5!)




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2