从powershell中的文件名中删除字符 [英] Remove character from file name in powershell
本文介绍了从powershell中的文件名中删除字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 powershell 的新手,想知道是否有办法从文件名中删除字符.我要删除的字符是一个破折号-",有时文件名中有 2 或 3 个破折号.是否可以重命名包含破折号的文件?
I'm new to powershell and wanted to know if there's a way to remove a character from a file name. The character I'm trying to remove is a dash "-" and sometimes there are 2 or 3 dashes in the file name. Is it possible to have it rename files that have a dash in them?
推荐答案
Get-Item .\some-file-with-hyphens.txt | ForEach-Object {
Rename-Item $_ ($_.Name -replace "-", "")
}
这个问题可能更适合超级用户.
This question may be more suitable for SuperUser.
这篇关于从powershell中的文件名中删除字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文