重命名,在DOS批处理文件多个文件 [英] Rename Multiple files with in Dos batch file

查看:137
本文介绍了重命名,在DOS批处理文件多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想所有的文件重命名文件夹* .TXT里面,
这样的结果将是
的1.txt,2.txt和3.txt,...

I wish to rename all files inside the folder *.txt, so the result will be "1.txt", "2.txt" and "3.txt", ....

我怎么可以这样做?

推荐答案

下面可以完成你在找什么。它采用了循环通过文本文件进行迭代,并发出呼地批处理文件做一个变量的命名和增量的另一位。

The following may accomplish what you are looking for. It uses a for loop to iterate through the text files and makes a "call" to another bit of the batch file to do the rename and increment of a variable.

修改更改数学运算由舍甫琴科提出清晰的解决方案。

Edit Change math operation to cleaner solution suggested by Andriy.

@echo off
set i=1
for %%f in (*.txt) do call :renameit "%%f"
goto done

:renameit
ren %1 %i%.txt
set /A i+=1

:done

这篇关于重命名,在DOS批处理文件多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆