これが他の場所で回答されている場合はお詫び申し上げます。他のフォーラムの投稿に書かれた下手な英語を理解するのに苦労しており、何が起こっているのかを本当に理解したいと思っています.
このコードはうまく機能します。
dim FileSys, source, destination, WSNet, theDate, theTime, computerName
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set WSNet = CreateObject("WScript.Network")
computerName = WSNet.computerName
theDate = Replace(Date, "/","-")
theTime = Replace(Time, ":",".")
source = "C:\source"
destination = "C:\destfolder"
if Not FileSys.FolderExists(destination) Then
WScript.echo "the destination: " & destination & " doesnt exist, it will now be created"
FileSys.Createfolder(destination)
FileSys.CopyFolder source, destination
Else
If FileSys.FolderExists(source) Then
FileSys.CopyFolder source, destination
Else
WScript.echo "ERROR: The source folder is not present, nothing will be copied"
End If
End If
しかし、この行を置き換えると:
destination = "C:\destfolder"
このようなもので:
destination = "C:\destfolder\" & computerName & "\" & theDate & "\" & theTime
の行に沿ってエラーが発生します。絞り込んで使用しても「パスが見つかりません」:
destination = "C:\destfolder\" & computerName
同じエラーが発生します。WScript.echo 行では、期待どおりに文字列が表示されます。
C:\destfolder\MYPC\22-05-2014\13.55.44
フォルダーを作成していないようです。問題は FileSys.CreateFolder メソッドにあるようです。誰か助けてもらえますか?
PS - ここでの私の全体的な目標は、いくつかのログ ファイルをある場所から別の場所にコピーすることですが、それらを日付と時刻のフォルダー名で並べ替えることです。