VBS脚本删除文件夹出错,没有权限
我在一个文件夹里有若干子文件夹,有些子文件夹中有CSF格式的文件,我现在想把这这些CSF文件移动到该文件夹的某子文件夹,移动操作完成之后,把包含这个CSF文件的文件夹删除掉,于是我写了一个VBS脚本,但却提示出错,脚本内容如下
Dim folderpath,destinationfolder
rem 源文件夹
folderpath="D:\\net\\"
rem 目录文件夹
destinationfolder="D:\\net\\net\\"
Set fso=CreateObject("Scripting.filesystemobject")
Set folder=fso.GetFolder(folderpath)
rem 遍历源文件夹中的子文件夹
For Each subfolder In folder.subfolders
If subfolder.path <> "D:\net\net" then
rem 遍历子文件夹中的子文件
For Each subfile In subfolder.files
rem 判断子文件的后缀名
If fso.GetExtensionName(subfile)="csf" Or fso.GetExtensionName(subfile)="CSF" then
rem 移动符合条件的文件到指定的文件夹
subfile.Move(destinationfolder)
rem 删除包含特定文件的文件夹
subfolder.Delete(True)
Exit For
End if
next
End if
next
MsgBox "move file sucessfully!"
set fso=nothing
set folder=nothing