在 Windows 上使用一个命令更改文件夹中所有文件的扩展名 [英] Changing all files' extensions in a folder with one command on Windows
问题描述
如何使用 Windows 命令行将数千个文件的扩展名更改为 *****.jpg
?
How can I use the Windows command line to change the extensions of thousands of files to *****.jpg
?
推荐答案
您可以使用ren
(如rename):
ren *.XXX *.YYY
当然,切换 XXX 和 YYY 以获得适当的扩展名.它将从 XXX 更改为 YYY.如果要更改所有扩展名,只需再次使用通配符:
And of course, switch XXX and YYY for the appropriate extensions. It will change from XXX to YYY. If you want to change all extensions, just use the wildcard again:
ren *.* *.YYY
递归地进行这项工作的一种方法是使用 FOR
命令.它可以与 /R
选项一起使用,以递归地将命令应用于匹配的文件.例如:
One way to make this work recursively is with the FOR
command. It can be used with the /R
option to recursively apply a command to matching files. For example:
for/R %x in (*.txt) do ren "%x" *.renamed
将从当前目录开始,递归地将所有 .txt
扩展名更改为 .renamed
.%x
是保存匹配文件名的变量.
will change all .txt
extensions to .renamed
recursively, starting in the current directory.
%x
is the variable that holds the matched file names.
而且,由于您有数千个文件,请务必等到光标再次开始闪烁以表明它已完成工作.
And, since you have thousands of files, make sure to wait until the cursor starts blinking again indicating that it's done working.
注意:这仅适用于 cmd.不适用于 Powershell 或 Bash
Note: this works only on cmd. Won't work on Powershell or Bash
这篇关于在 Windows 上使用一个命令更改文件夹中所有文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!