我想为所有文件添加 .zip 扩展名。我试过了,但是没有用:
ls | awk '{print $1 " " $1".zip"}' | xargs mv -f
答案1
for f in * ; do
mv "$f" "$f.zip"
done
答案2
rename 's/$/\.zip/' *
不要用xargs
那種方式!
答案3
搜索-一些链接:
男人改名:
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...
答案4
这应该可以解决问题:
mmv "./*" "./#1.zip"
(虽然我不知道你为什么要这样做……)