中国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-02 16:45
48,038 topics / 350,123 posts / today 1 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Help! How to rename files with batch processing
Printable Version  1,660 / 4
Floor1 gene771771 Posted 2006-12-08 10:25
初级用户 Posts 77 Credits 105 From 重庆
A friend has a server. He asked me that he has a directory at d:\, and there are many subdirectories in d:\html, and there are many *.htm files in the subdirectories. How to use batch processing to change all *.htm to *.html. Please ask experts for guidance.
Floor2 zh159 Posted 2006-12-08 10:31
金牌会员 Posts 1,467 Credits 3,687
```
@echo off
for /f "delims=" %%i in ('dir/b/s *.htm^|find ".htm"') do echo "%%i" "%%il"
pause
```
Floor3 namejm Posted 2006-12-08 10:50
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Brother zh159, the previous plan of using dir followed by find still might find folder names ending with .htm because dir didn't filter out folders. Adding the parameter /a-d to dir can eliminate the need for find. Modify the demo code based on 2F as follows:
Floor4 gene771771 Posted 2006-12-08 10:53
初级用户 Posts 77 Credits 105 From 重庆
Thank you very much, moderator. Because my internet speed is slow, just now I thought I didn't post successfully and reposted it again, but just now I found it was duplicated. I'm sorry, I didn't intentionally spam. Please delete that post. Thank you.
Floor5 3742668 Posted 2006-12-08 12:28
荣誉版主 Posts 718 Credits 2,013
```
@echo off
pushd d:\html
ren *.htm *.html 2>nul
for /r /d %%i in (*) do ren "%%i\*.htm" "%%i\*.html" 2>nul
popd
exit /b 0
```
Theoretically it works, not tested.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023