如何解决如何使用命令行在 Windows 10 中查找和替换文件名中的字符?
我想用文件名中的空格 (_
) 替换所有下划线字符 (
)。
当我有很多 _
字符要替换时,如何快速完成此操作?
解决方法
您可以使用 PowerShell 的 Rename-Item
command:
Get-Item .\path\to\file_name_with_underscores.txt |Rename-Item -NewName {$_.Name.Replace("_"," ")}
如果需要,您可以一次对多个文件执行此操作:
# all relevant files in the current folder
Get-ChildItem . -File -Filter *_* |Rename-Item -NewName {$_.Name.Replace("_"," ")}
# all relevant files in the current folder and all subfolders
Get-ChildItem . -File -Recurse -Filter *_* |Rename-Item -NewName {$_.Name.Replace("_"," ")}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。