来源:网络位置 UNC 路径 目标:远程服务器并希望在此服务器上运行脚本。
我一直在寻找许多脚本,但无法满足我的确切要求。下面是看起来更接近我的要求的 VBscript,但这不适用于子文件夹,它看起来是特定于几个小时的,我正在寻找特定于多种文件类型的天数。任何帮助深表感谢 ?
提前感谢您帮助我!
我可以接受任何其他脚本,但必须满足我的要求。
==================================================== ====
Option Explicit
On Error Resume Next
Dim fso, FileSet, Path, File, DDiff, Date1, Date2, DestPath
Path = "C:\source"
DestPath = "\\server\destination\"
'DestPath must end with \
FileSet = GetDirContents(Path)
For each File in FileSet
Set File = fso.GetFile(Path & "\" & File)
Date1 = File.DateLastModified
'.DateCreated if you want 24hrs of life, this example is 24hrs since last written
Date2 = Now()
DDiff = Abs(DateDiff("h", Date1, Date2))
If DDiff >= 168 Then
If Not fso.FileExists(DestPath & File.Name) Then
File.Move DestPath
'wscript.echo File.Name
Else
wscript.echo "Unable to move file [" & File.Name & "]. A file by this name already exists in the target directory."
End If
End If
Next
Function GetDirContents(FolderPath)
Dim FileCollection, aTmp(), i
Set fso = CreateObject("Scripting.FileSystemObject")
Set FileCollection = fso.GetFolder(FolderPath).Files
Redim aTmp(FileCollection.count - 1)
i = -1
For Each File in FileCollection
i = i + 1
aTmp(i) = File.Name
Next
GetDirContents = aTmp
End Function
==================================================== =======================