Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare file to system date and time

Status
Not open for further replies.

daillest319

Programmer
Apr 9, 2012
29
0
0
US
I'm trying to write a script to check a files date and time so i know its ready to upload. I'm not sure what im doing wrong but i need to check if the file is greater than 10:00AM and also greater than yest date.



Code:
Dim objFS, strFile
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "C:\TEST\test.txt"

if objFS.GetFile(strFile).DateLastModified > date - 1 & "10:00:00 AM" then

WScript.Echo "Upload is ready"
else
WScript.Echo "Upload is not ready"
end if
 
> Date - 1 + #10:00:00 AM#

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thank you so much guys. I used PHV method and it worked perfect.
 
I have another quest regarding this....i was trying to do the same thing to another file but the .DateLastModified must equal today's date... i tried multiple ways and nothing works...its looks like its not recognizing the date and if i put...... .DateLastModified >= date <--- this worksbut doesnt seem right.

Code:
Dim objFS, strFile
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "C:\TEST\test.txt"

if objFS.GetFile(strFile).DateLastModified = date then

WScript.Echo "Upload is ready"
else
WScript.Echo "Upload is not ready"
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top