【发布时间】:2012-10-11 20:20:03
【问题描述】:
基本上,我需要一个脚本来将文件移动到另一个已被访问和修改过的文件夹。
我是脚本新手,所以这可能是一个简单的问题,但我很难过。这是我得到的错误:
脚本:C:\Users\bmcwilliams\Desktop\pssitest.vbs
线路:17
字符:10
错误:文件已存在
代码:800A003A
来源:Microsoft VBScript 运行时错误
目标文件夹是空的,所以我不确定发生了什么。
下面是我的代码。它是根据这篇文章中列出的代码修改的:
How to move files from a directory to another directory based on file size
' use a default source path
dim sourcepath: sourcepath = "C:\users\bmcwilliams\Desktop\TestUncompleted"
' use a default destination path
dim destinationpath: destinationpath = "C:\users\bmcwilliams\Desktop\TestCompleted"
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim sourcefolder: set sourcefolder = fso.GetFolder(sourcepath)
' loop through each file in the directory, compare size property against
' the limit and copy as appropriate
dim file, count: count = 0
for each file in sourcefolder.Files
dim createDate: createDate = file.DateCreated
dim modifyDate: modifyDate = file.DateLastModified
if createDate <> modifyDate Then
file.Move destinationpath
count = count + 1
end if
next
WScript.Echo("complete: " & count & " file(s) moved")
有什么想法吗?非常感谢任何输入。谢谢!
【问题讨论】:
标签: vbscript move datecreated modified-date