尝试移动文件并添加日期时间戳

Trying to move a file and add a date timestamp

过去几天一直在阅读一些问题和答案,但无法弄清楚我哪里出错了。如果能提供任何帮助,我将不胜感激。所以我试图在拉入新副本之前将文件移动到不同的折叠,但我希望我要移动的那个在之后有一个日期时间戳(这样我以后就有了它的记录)。抱歉,如果这有点粗糙,这是我第二次尝试做这样的事情。

DIM Date1

Date1 = Now()
DIM FSO 
SET FSO=CreateObject("Scripting.FileSystemObject")


FSO.Movefile "I:\This is it\External Storage\Replen\Data\LOCATIONS\*ITEM INVENTORY BY PURCHASE ORDER.csv*", "I:\This is it\External Storage\Replen\Data\LOCATIONS\ITEM INVENTORY BY PURCHASE ORDER\" & Date1.csv

With CreateObject("Scripting.FileSystemObject")

.MoveFile "C:\Users\s.c\Downloads\*.csv*", "I:\This is it\External Storage\Replen\Data\LOCATIONS\"
End With

此代码会将 sSourceFile(在您的情况下为 ITEM INVENTORY BY PURCHASE ORDER.csv)移至 sDestinationFolder 并使用您计算机的日期重命名(至 YYYY-MM-DD.csv):

Dim sSourceFile
Dim sDestinationFolder
Dim sDate
Dim objFSO

sSourceFile = "I:\This is it\External Storage\Replen\Data\LOCATIONS\ITEM INVENTORY BY PURCHASE ORDER.csv"
sDestinationFolder = "I:\This is it\External Storage\Replen\Data\LOCATIONS\ITEM INVENTORY BY PURCHASE ORDER\"

' Build date string
sDate = Year(Now) & "-" & Month(Now) & "-" & Day(Now)

' Create FileSystem object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check if File exists
If objFSO.FileExists(sSourceFile) Then

    ' Move file
    objFSO.Movefile sSourceFile, sDestinationFolder & sDate & ".csv"

Else
    ' File does not exist
End If