Chinaunix首页 | 论坛 | 博客
  • 博客访问: 158965
  • 博文数量: 31
  • 博客积分: 2085
  • 博客等级: 大尉
  • 技术积分: 350
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-07 13:16
文章分类

全部博文(31)

文章存档

2014年(1)

2011年(4)

2010年(6)

2009年(2)

2008年(2)

2007年(5)

2006年(8)

2005年(3)

我的朋友

分类: WINDOWS

2010-06-18 16:56:29

 
去掉文件夹和文件名字中的特殊字符 % & ?,因为把他们传输到sharepoint 时会有问题
 

apath=InputBox("Input root folder's full path")
replaceFileName(apath)

Function replaceFileName(ByVal dPath)
   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oFolder = oFSO.GetFolder(dPath)
   Set oFiles = oFolder.Files
   set oSubFolders=oFolder.Subfolders
 
    For Each oFile In oFiles
        if instr(oFile.name,"&") then oFile.name= Replace(oFile.name,"&","_",1,-1,1)
        if instr(oFile.name,"%") then oFile.name= Replace(oFile.name,"%","_",1,-1,1)
        if instr(oFile.name,"?") then oFile.name= Replace(oFile.name,"?","_",1,-1,1)
    Next
    For Each subFolder In oSubFolders
        if instr(subFolder.name,"&") then    subFolder.name= Replace(subFolder.name,"&","_",1,-1,1)
        if instr(subFolder.name,"%") then    subFolder.name= Replace(subFolder.name,"%","_",1,-1,1)
        if instr(subFolder.name,"?") then    subFolder.name= Replace(subFolder.name,"?","_",1,-1,1)
        replaceFileName(subFolder.path)
    Next
End Function


阅读(752) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~