重命名适用于一个但不适用于另一个

时间:2023-01-27 23:30:28

My batch file has the following code:

我的批处理文件包含以下代码:

rename And.mk Andold.mk
rename Test1.txt And.mk

When I execute the batch file, it renames Test1.txt to And.mk, but does not rename And.mk to Andold.mk. Why is this happening?

当我执行批处理文件时,它将Test1.txt重命名为And.mk,但不会将And.mk重命名为Andold.mk。为什么会这样?

  • I tried with ren and REN as well.. but no change
  • 我也尝试过ren和REN ..但没有变化

  • I checked file permission of And.mk and gave it full permission.. but still did not work
  • 我检查了And.mk的文件许可并给予了完全许可..但仍然无法正常工作

  • The folder shows two And.mk now without any conflict...
  • 该文件夹显示两个And.mk现在没有任何冲突...

* - Am working on Windows7 by the way....

* - 顺便说一句,我正在使用Windows7 ....

@Andriy - Thanks for your reply.1) I checked Registered file types...mk files are present by default 2)I am not changing the name of Test1.txt manually..the whole purpose of this is for the batch file to do the work for me

@Andriy - 感谢您的回复.1)我检查了注册文件类型...默认情况下存在mk文件2)我没有手动更改Test1.txt的名称..这个目的的全部目的是批处理文件为我做的工作

1 个解决方案

#1


0  

You might want to wait after renaming the first file for sometime, maybe the file is still being processed and thus no other file can be named the same name, so try the following:

您可能希望在重命名第一个文件一段时间后等待,也许该文件仍在处理中,因此没有其他文件可以命名为相同的名称,因此请尝试以下操作:

rename And.mk Andold.mk
timeout /T 500
rename Text1.txt Andmk

#1


0  

You might want to wait after renaming the first file for sometime, maybe the file is still being processed and thus no other file can be named the same name, so try the following:

您可能希望在重命名第一个文件一段时间后等待,也许该文件仍在处理中,因此没有其他文件可以命名为相同的名称,因此请尝试以下操作:

rename And.mk Andold.mk
timeout /T 500
rename Text1.txt Andmk