文件夹结构如:
-rootDir
- subDirA
-1.txt
-2.txt
-...
-subDirB
-1.txt
-2.txt
-...
需求:将一个文件夹中(包括所有子目录中)所有同类文件(如txt文件)的后缀名改成另外一种类型文件(如 doc文件)。
使用windows bat批处理
changeSuffixName.bat
@echo off
D:
cd D:\Test\rootDir
for /f "tokens=* delims=" %%i in ('dir /b/s *.txt') do (
rename "%%i" "*.doc"
)
exit
do 关键字前后都有空格
【参考文献】:
https://www.cnblogs.com/nethrd/p/9244046.html