重命名文件并删除“点”并将其替换为 _'
我在名称类似于 abcd.15678 的文件夹中有一组文件 我想删除 .并将其替换为 _
请建议使用 windows 命令来执行此操作
I have set of files in a folder with name like abcd.15678
I want to remove the . and replace it with _
Pls suggest the windows command to do this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此解决方案重新发布自 如何在 Windows 中批量重命名文件:重命名多个文件的 4 种方法作者:Chris Hoffman
PowerShell 为重命名文件提供了更大的灵活性命令行环境。使用 PowerShell,您可以将一个命令(在 PowerShell 术语中称为“commandlet”)的输出通过管道传输到另一命令,就像在 Linux 和其他类 UNIX 系统上一样。
首先,打开 Powershell ISE,然后导航到包含您的文件和文件夹的目录(文件夹)想要使用以下命令重命名:
您需要的两个重要命令是 Dir,它是列表当前目录中的文件,以及重命名项目,它重命名项目(在本例中为文件)。将 Dir 的输出通过管道传递给 Rename-Item 即可开始工作。
启动 PowerShell ISE 后,使用 cd 命令进入包含文件的目录。您应该将这些文件放在它们自己的目录中,这样就不会意外地重命名其他文件。
例如,假设我们不希望文件名中包含点字符 - 我们宁愿使用下划线。
以下命令列出当前目录中的文件,并将列表通过管道传递给 Rename-Item。 Rename-Item 将每个点字符替换为下划线。
如果您需要执行帮助,请参阅 Microsoft 有关 Rename-Item commandlet 的文档其他更高级的操作。
This solution is reposted from How to Batch Rename Files in Windows: 4 Ways to Rename Multiple Files by Chris Hoffman
PowerShell offers much more flexibility for renaming files in a command-line environment. Using PowerShell, you can pipe the output of one command – known as a “commandlet” in PowerShell terms — to another command, just like you can on Linux and other UNIX-like systems.
First of all, open Powershell ISE and then navigate to the directory (folder) that has the files and folders you'd like to rename by using this command:
The two important commands you’ll need are Dir, which lists the files in the current directory, and Rename-Item, which renames an item (a file, in this case). Pipe the output of Dir to Rename-Item and you’re in business.
After you launch PowerShell ISE, use the cd command to enter the directory containing your files. You should put the files in their own directory so you don’t accidentally rename other files.
For example, let’s say we don’t want the dot character in our file names – we’d rather have an underscore instead.
The following command lists the files in the current directory and pipes the list to Rename-Item. Rename-Item replaces each dot character with an underscore.
Consult Microsoft’s documentation on the Rename-Item commandlet if you want help performing other, more advanced operations.
没有 Windows 命令可以执行此操作。您应该考虑编写某种脚本来获取目录列表并枚举每个条目:将点更改为下划线,并相应地调用 Windows 重命名命令。
There isn't a windows command to do this. You should consider writing a script of some sort that obtains a directory listing and enumerates through each entry: changes the dot to an underscore, and calls the windows rename command appropriately.
实际上这应该有效:
Actually this should work :