我想批量重命名特定子目录中的所有文件。为什么以下语法出错?
RENAME .\webapps\*.war .\webapps\Test.war
答案 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也可能有用。