0

我有大量文件要在我的 Windows 8 计算机上重命名为固定模式。我正在寻找一种方法,以便我可以以任何方式快速重命名文件:就像执行此操作的任何软件或命令窗口上的任何命令一样。

以下是我需要做的:

原始文件名:Body Begger Power.docx.htm 需要这个是:body-begger-power.html

4

2 回答 2

3

从根目录你可以试试这个:

Get-ChildItem -Force -Recurse | Move-Item -Destination {$_.FullName.ToLower() -replace ' ', '-'}

我没有看到任何删除扩展的模式。如果所有文件都是 docx.html 并且您希望将它们更改为 html,您可以简单地进行另一个替换,如下所示:

Get-ChildItem -Force -Recurse | Move-Item -Destination {($_.FullName.ToLower() -replace ' ', '-') -replace '.docx.htm$', '.html'}

于 2013-05-16T06:41:16.827 回答
1
for /r %i in (.) do if exist "%i\body begger power.docx.htm" ECHO ren "%i\body begger power.docx.htm" body-begger-power.html

从提示将扫描树.(当前目录 - 或替换您想要开始的目录名称)。这将简单地将检测到的文件名 ECHO 显示到屏幕上 - 您需要删除 ECHO 关键字才能真正重命名文件。

于 2013-05-16T11:58:05.240 回答