重命名CMD多个文件 [英] Rename multiple files in cmd

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

问题描述

如果我有一个目录多个文件,并要追加一些自己的文件名,而不是扩展,我会怎么做呢?

我曾尝试以下,以测试文件FILE1.TXT和FILE2.TXT:

 仁* .TXT * 1.1.txt

这重命名文件fil​​e1.1.txt和file2.txt1.1.txt

我要的文件是文件1 1.1.txt和file2 1.1.txt

这会不会是从CMD可能或者我需要有一个bat文件做到这一点?有关PowerShell的什么?


解决方案

  FOR / Fdelims =%% i的('DIR / B /广告* .TXT)做仁%%〜我%%〜1.1妮%%〜黄宗羲

如果您使用简单的循环而不 /˚F参数,已重命名的文件将被再次改名。

If I have multiple files in a directory and want to append something to their filename, but not to the extension, how would I do this?

I have tried the following, with test files file1.txt and file2.txt:

ren *.txt *1.1.txt

This renames the files to file1.1.txt and file2.txt1.1.txt

I want the files to be file1 1.1.txt and file2 1.1.txt

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"

If you use the simple for loop without the /f parameter, already renamed files will be again renamed.

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

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