2017-08-10 89 views
0

我想重命名下面的文件名。您可以看到一些文件具有“.DSD”,因此可以使用 。 所以我想删除这些“.DSD”问题重命名子目录中的文件

我只是闯民宅等从这里如

for /r %x in (*.DSD) do ren "%x" *.dad 

但它不工作,所以 我应该这样做有什么ansering?

before          after 
DDS1_150223.cpj.DSD       DDS1_150223.cpj     
DDS1_150211.cpj.DSD       DDS1_150211.cpj 
72 ranndom value.xls      72 ranndom value.xls 
FREQUENCY_AGILE_MEM.mif.DSD     FREQUENCY_AGILE_MEM.mif 
....          ... 
+0

难道他们都在同一个目录中,还是有子目录,您还需要处理? – SomethingDark

+0

@SomethingDark一堆文件也包含在子目录中。 –

回答

1

这个命令将工作:

for /r %a in (*.DSD) do @move "%a" "%~pa%~na" 

以上。利用一些可选语法的命令:

%~I   - expands %I removing any surrounding quotes (") 
%~fI  - expands %I to a fully qualified path name 
%~dI  - expands %I to a drive letter only 
%~pI  - expands %I to a path only 
%~nI  - expands %I to a file name only 
%~xI  - expands %I to a file extension only 
%~sI  - expanded path contains short names only 
%~aI  - expands %I to file attributes of file 
%~tI  - expands %I to date/time of file 
%~zI  - expands %I to size of file 
%~$PATH:I - searches the directories listed in the PATH 
       environment variable and expands %I to the 
       fully qualified name of the first one found. 
       If the environment variable name is not 
       defined or the file is not found by the 
       search, then this modifier expands to the 
       empty string 
+0

谢谢,但当我遇到一些错误信息,当我运行时像D:\ Downloads \ Seeker_20160719>/r%a在(* .DSD)中执行@move“%a”“%〜pa%〜na” 在批处理参数中使用路径运算符 替换无效:%〜pa%〜na“ 对于有效格式,请键入CALL /?或FOR /? bat.bat此时是意外的 –

+0

您运行了此命令在命令提示符窗口或批处理文件中? – liuqx

+0

我用你的命令 –