ソース: ネットワークの場所 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
================================================== ======================