在cmd中重命名多个文件 [英] Rename multiple files in cmd
本文介绍了在cmd中重命名多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在一个目录中有多个文件,并且想要将文件附加到其文件名,而不是扩展名,我该怎么办?
If I have multiple files in a directory and want to append something to their filenames, but not to the extension, how would I do this?
以下,带有测试文件 file1.txt
和 file2.txt
:
I have tried the following, with test files file1.txt
and file2.txt
:
ren *.txt *1.1.txt
将文件重命名为 file1.1.txt
和 file2.txt1.1.txt
我想要的文件 file1 1.1.txt
和 file2 1.1.txt
这是否可能从cmd或者我需要一个bat文件来做这个?
Will this be possible from cmd or do I need to have a bat file to do this? What about PowerShell?
推荐答案
for /f "delims=" %%i in ('dir /b /a-d *.txt') do ren "%%~i" "%%~ni 1.1%%~xi"
如果在没有 / f
参数的情况下使用简单的文件将再次重命名。
If you use the simple for
loop without the /f
parameter, already renamed files will be again renamed.
这篇关于在cmd中重命名多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文