中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-12 16:28
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] Problem changing extensions with FOR
Printable Version  736 / 2
Floor1 cyz678990 Posted 2010-04-08 22:47
新手上路 Posts 6 Credits 8
I first used FOR to rename .EXE to .EXE.BAK
@echo off
set pth=%cd%
for /r "%pth%" %%a in (*.EXE) do move /y "%%a" "%%a.BAK"

Later I wanted to try changing them back, but I don't know what's wrong with the statement below. I kept looking it over again and again, but it's still not right.
@echo off
set pth=%cd%
for /r "%pth%" %%a in (*.BAK) do (
set file=%%a
move /y "%%a" "%file:~0,-4%"
)
Could some expert give me some pointers?
Floor2 Hanyeguxing Posted 2010-04-08 23:07
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂

You didn't use delayed variable expansion.
Floor3 cyz678990 Posted 2010-04-08 23:10
新手上路 Posts 6 Credits 8
Oh, thanks.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023