下面的代码执行成功:
Sub xxx()Dim wsh
Set wsh = CreateObject("WScript.Shell")
wsh.Run "清旦渗notepad.exe"
Set wsh = Nothing
End Sub
我认为,迟物你修改wsh.Run的参数,可以调用系统的move命令实现你的功能,估计是这样,你可能需要调试答脊:
Sub movefile(PTH, FILES, PTH2)Dim wsh
Set wsh = CreateObject("WScript.Shell")
wsh.Run "MOVE /Y " & PTH & "\" & FILES & " " & PTH2 & "\"
Set wsh = Nothing
End Sub
同意楼上看法,先判断是否存在,您说“文件名重复的文件内容也是完全相同的”,所以如果判断 c:\processed中已有,则不移动:Sub movefile(PTH, FILES, PTH2)
Dim MyFileObject
Set MyFileObject = CreateObject("Scripting.FileSystemObject")
For Each file In MyFileObject.getfolder(PTH).FILES
If Dir(PTH2 &"\" &Dir(file)) = "" Then ‘判断PTH2中是否已有
MyFileObject.movefile PTH &"\" &Dir(file), PTH2 &"\"
End If
Next
End Sub
Kill myPath2Set Fil = Fso.OpenTextFile(myPath2, 8, 1) '打开文本文件
不用清橡棚空雹如雀,源早直接删除文件
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)