中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-08-09 15:37
47,811 主题排行 / 349,896 发帖 / 今日 1 篇 / 48,254 会员排行
DOS批处理 & 脚本技术(批处理室) » 【求助】for 循环里面怎么改变路径
可打印版本  667 / 2
第1楼 terrytong 发表于 2008-09-05 11:33
中级用户 发帖 115 积分 240
【求助】for 循环里面怎么改变路径
帮我看看下面的P啊,不知道为什么不能在For里面改路径啊?

@echo off
title set Copy file
mode con cols=100 lines=20
setlocal enabledelayedexpansion
if exist U:\terry\terry.txt goto start
net use u: \\10.5.1.101\testlog npg /user:administrator
if not exist U:\terry\terry.txt goto nonet

:start
d:
set tm=%time:~0,2%%time:~3,2%
set dt=%date:~10,4%%date:~4,2%%date:~7,2%
set new=%tm: =0%
for /r d: %%a in (*.cfg) do (
set n=0
set temp=%%a
set defin=!temp:~7,3!
if !defin!==Rev (
set mo=!temp:~19,9!
set dirc=!temp:~0,29!) else (
set mo=!temp:~21,9!
set dirc=!temp:~0,31!)
cd !dirc!
for /f "skip=10 tokens=1,2 delims==" %%b in (SFIS.cfg) do (
set /a n+=1
set temp2=%%c
if "!n!"=="1" set phase=!temp2!&&echo phase=!phase!)
cd !dirc!log
for /r %%d in (*.log) do (
set temp3=%%d
set name=!temp3:~33,8!
CALL CALL !!!!new!!!!
if !new!==0000 (
ren !name!.log !name!-!mo!--!phase!.log
copy !name!-!mo!--!phase!.log E:\testlog
copy !name!-!mo!--!phase!.log U:\CastlePoint_Intel)
)
cd !dirc!testlog
if not exist *.txt goto end
for /r %%e in (*.txt) do (
set temp4=%%e
set name2=!temp4:~37,7!
ren !name2!.txt !name2!--!dt!!new!.txt
copy !name2!--!dt!!new!.txt E:\testlog
copy !name2!--!dt!!new!.txt U:\CastlePoint_Intel&&del !name2!--!dt!!new!.txt)
)
goto :end


:nonet
color 47
echo *********************************************************************************
Echo.
Echo.
Echo.
Echo.
Echo.
echo the network is not available, please check if the U: is accessable and then try again
Echo.
Echo.
Echo.
Echo.
echo *********************************************************************************
ping/n 4 127.4>nul



:end

[ Last edited by terrytong on 2008-9-5 at 12:52 PM ]
第2楼 terrytong 发表于 2008-09-05 12:57
中级用户 发帖 115 积分 240
后来我试试不用CD
for /f "skip=10 tokens=1,2 delims==" %%b in (SFIS.cfg) do (
set /a n+=1
set temp2=%%c
if "!n!"=="1" set phase=!temp2!&&echo phase=!phase!)
这句可以正确运行.
但是下面两个For都不行,
for /r !dirc!log %%d in (*.log) do (
set temp3=%%d
set name=!temp3:~33,8!
CALL CALL !!!!new!!!!
if !new!==0000 (
ren !name!.log !name!-!mo!--!phase!.log
copy !name!-!mo!--!phase!.log E:\testlog
copy !name!-!mo!--!phase!.log U:\CastlePoint_Intel)
)
for /r !dirc!testlog %%e in (*.txt) do (
set temp4=%%e
set name2=!temp4:~37,7!
ren !name2!.txt !name2!--!dt!!new!.txt
copy !name2!--!dt!!new!.txt E:\testlog
copy !name2!--!dt!!new!.txt U:\CastlePoint_Intel&&del !name2!--!dt!!new!.txt)

高手们帮忙点拔下啊。

[ Last edited by terrytong on 2008-9-5 at 12:59 PM ]
第3楼 huahua0919 发表于 2008-09-05 14:07
银牌会员 发帖 780 积分 1,608
用cd/d命令.
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023