issue重命名子目录中的文件

时间:2017-08-10 01:43:56

标签: windows batch-file cmd

我正在尝试将以下文件名重命名。 你可以看到一些文件有“.DSD”。 所以我想删除这些“.DSD”

我只是在这里引用其他的asering,例如

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

但它不起作用 我该怎么做呢?

    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
....                                        ...

1 个答案:

答案 0 :(得分: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