如何在subdir中批量重命名特定文件类型的文件?

时间:2014-03-20 10:13:53

标签: windows batch-file

我想批量重命名特定子目录中的所有文件。为什么以下语法出错?

RENAME .\webapps\*.war .\webapps\Test.war

2 个答案:

答案 0 :(得分:2)

您不能rename使用包含路径的目标名称。

RENAME .\webapps\*.war Test.war

应该有用。

答案 1 :(得分:0)

您的陈述中存在一些混淆:您是否要将所有文件更改为相同的名称?这是不可能的。

您可能以错误的方式使用rename,请参阅man rename

NAME
   rename - renames multiple files

SYNOPSIS
   rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

DESCRIPTION
   "rename" renames the filenames supplied according to the rule specified as the first argument.    The perlexpr argument is a Perl expression which is
   expected to modify the $_ string in Perl for at least some of the filenames specified.  If a given filename is not modified by the expression, it will not
   be renamed.  If no filenames are given on the command line, filenames will be read via standard input.

   For example, to rename all files matching "*.bak" to strip the extension, you might say

           rename 's/\.bak$//' *.bak

   To translate uppercase names to lower, you'd use

           rename 'y/A-Z/a-z/' *

OPTIONS
   -v, --verbose
           Verbose: print names of files successfully renamed.

   -n, --no-act
           No Action: show what files would have been renamed.

   -f, --force
           Force: overwrite existing files.

This post也可能有用。

相关问题