如何在vbscript中仅复制和删除基于修改日期的文件?
源文件位置中的所有文件都已复制到中 目标文件夹。 只有在我的 datefrom=12/07/2014和我的 日期:2014年9月12日如何在vbscript中仅复制和删除基于修改日期的文件?,vbscript,Vbscript,源文件位置中的所有文件都已复制到中 目标文件夹。 只有在我的 datefrom=12/07/2014和我的 日期:2014年9月12日 文件名:修改日期 文件1 2014年7月12日 文件2 2014年9月12日 文件3 2015年6月1日 这是我的密码 Dim ObjFso Set objFSO = CreateObject("Scripting.FileSystemObject") Dim StrSourceLocation Dim StrDestina
- 文件名:修改日期
- 文件1 2014年7月12日
- 文件2 2014年9月12日
- 文件3 2015年6月1日
Dim ObjFso
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim StrSourceLocation
Dim StrDestinationLocation
Dim StrSourceFileName
dim SourceLocation
dim DestinationLocation
dim datefrom, dateto, datectr
datefrom = DateValue("01/01/2015")
dateto = DateValue("01/01/2015")
datefrom = InputBox ("date from: (mm/dd/yyyy)")
dateto = InputBox ("date to: (mm/dd/yyyy)")
StrSourceLocation = InputBox ("source:")
StrDestinationLocation = InputBox ("destination:")
datectr = datefrom
dateto = dateto
intYear=0
intMonth=0
indDay=0
intFileCtr=0
intFileDayCtr=0
SourceLocation = StrSourceLocation + "\*.*"
DestinationLocation = StrDestinationLocation + "\"
Const OverwriteExisting = True
Do Until datectr>dateto
intYear=Year(datectr)
intMonth=Month(datectr)
intDay=Day(datectr)
for each f in objFSO.Getfolder(StrSourceLocation).Files
if Year(f.DateLastModified) = intYear And Month(f.DatelastModified) = intMonth And Day(f.DateLastModified) = intDay Then
objFSO.CopyFile SourceLocation , DestinationLocation, OverwriteExisting
objFSO.DeleteFile(SourceLocation), True
end if
Next
datectr=DateAdd("d", 1, datectr)
datectr = DateValue(datectr)
Loop
我不知道你在干什么。日期在VBS中很简单
If DateValue("01/01/1980") < DateValue("01/01/1990") or DateValue("01/01/1980") > DateValue("01/01/1960") then
' blah
End If
如果DateValue(“01/01/1980”)DateValue(“01/01/1960”),则
“废话
如果结束
是如何检查范围内的日期
还有类似的
DateSerial
。日期是数字,从过去的一天(公元01/01/100年)起x天,时间是一个分数,这是一天的分数(下午12点是0.5)。我有一系列文件,先生,例如:文件1文件2和文件3。我只想复制目标文件夹中的文件1和文件2,并删除源文件夹中的文件1和文件2。因此,文件3将保留在源文件夹中,而文件1和文件2已移动到目标文件夹中。但这3个文件已复制到目标文件夹中,并删除了源文件夹中的3个文件。您好,先生。。我想我解决了这个问题。。objFSO.CopyFile f,DestinationLocation,覆盖现有的objFSO.DeleteFile(f),True