中国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 00:43
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] Display filenames after deleting certain characters (DIR)
Printable Version  910 / 2
Floor1 sea2moon Posted 2010-09-03 12:01
初级用户 Posts 23 Credits 47
Under one folder, I created several TXT files named test*

I want to use a batch file to display the filenames after deleting est
that is, display t*.txt

Why doesn't it work when written like this:

@echo off
setlocal enabledelayedexpansion
for /f %%i in ('dir /b *.*') do (
set var=%%~nxi
set !var=%var:est=%!
echo !var!)
pause

Thanks in advance, and it'd be best if you could analyze it too
Floor2 kakenhi Posted 2010-09-03 19:23
初级用户 Posts 21 Credits 21
It's not set !var=%var:est=%!, it's set "var=!var:est=!"


[ Last edited by kakenhi on 2010-9-3 at 19:24 ]
Floor3 sea2moon Posted 2010-09-03 22:10
初级用户 Posts 23 Credits 47
Thanks~
Tested it, it works...
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023