脚本删除文件名的特殊字符 [英] Script to remove special characters from filenames
本文介绍了脚本删除文件名的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含大量文件的文件夹。很多的文件名有'%'和/或'和;'在其中的字符。
I have a folder containing a large number of files. A lot of the filenames have '%' and/or '&' characters in them.
e.g. Test&doc.pdf
e.g Test%doc.doc
有没有一种快速的方法我可以删除'%'和'和;'使用Windows批处理文件,VBScript或类似的文字?
Is there a quick way I could remove the '%' and '&' characters using a windows batch file, vbscript or something similar?
所有帮助将大大AP preciated。
All help will be greatly appreciated.
感谢。
推荐答案
我很快抛出了一起,没有测试,但是,这个VBScript中应该做的伎俩。如果你需要一个像文件夹递归更换等花哨的东西告诉我。
I've quickly thrown that together and didn't test it, but this VBScript should do the trick. Tell me if you need fancy stuff like folder recursive replacing etc.
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Your folder here
objStartFolder = "X:\MYFOLDER"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set regEx = New RegExp
'Your pattern here
regEx.Pattern = "[&%]"
Set colFiles = objFolder.Files
For Each objFile in colFiles
objFile.Rename(regEx.Replace(objFile.Name, "")
Next
这篇关于脚本删除文件名的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文