重命名文件会覆盖部分文件名

发布于 2024-10-08 10:32:56 字数 189 浏览 0 评论 0原文

我有一个充满文件的目录,我想将它们重命名为在原始文件名前面添加 TA_ 。 file1.txt 应重命名为 TA_file1.txt。我得到的是 TA_e1.txt 。

ren "c:*.txt" "TA_*.txt" 是我尝试使用的命令。

文件名的长度各不相同,无论我尝试什么,它总是会覆盖我的文件名的前 3 个字符......

I ahve a directory full of files, and I want to rename each of them to have TA_ in front of the original file name. file1.txt should be renamed to TA_file1.txt. What I am getting is TA_e1.txt instead.

ren "c:*.txt" "TA_*.txt" is the command I am trying to use.

The file names are all of various lengths, and no matter what I try, it always overwrites the first 3 characters of my file name....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

誰ツ都不明白 2024-10-15 10:32:56

一个简单的行是:

for %i IN (*.txt) DO ren "%i" "TA_%i"

这会循环遍历所有文件 (*.txt),并将 %i 变量中的名称传递给 ren 命令。然后,ren 可以使用 %i 内容以您所需的前缀对其进行扩展。

该命令仅适用于当前目录中的文件。对于更复杂的事情,您应该编写一个批处理文件。如果您需要帮助,请回来。

A simple one liner would be:

for %i IN (*.txt) DO ren "%i" "TA_%i"

This loops over all files (*.txt) and passes their name in the %i variable to the ren command. ren can then use the %i content to expand it with your desired prefix.

The command will only work for files in the current directory. For more complex things you should write a batch file. Come back if you need help with that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文