File time in minutes
Moderators: JRL, Dorian (MJT support)
File time in minutes
I'm looking for an easier way to get the file time. I realize there is a command for the date, however, I want to get the time as well. The only way I have been able to do it is to use the Dos Dir command and then go in and parse the time out.
Does anyone know of an easier way?
Does anyone know of an easier way?
Example didn't work
Your example is exactly what I want to do; however, I copied and pasted it into macro scheduler, changed the file name to one that exists and when run Macro Scheduler closed. I checked on the VB Script help pages, now that I know what to look for and saw a similar example, I copied and pasted that one and it didn't run either. Any ideas as to why? Syntax error?
The example returns the file date but doesn't do anything with it - so of course if you run it nothing much will happen! Try adding the following line to the end of the script if you want it to _do_ something:
MessageModal>time
Then it will stop and show you the time.
A variable containing the time isn't the most animated creature in the world, but it is what you asked for
MessageModal>time
Then it will stop and show you the time.
A variable containing the time isn't the most animated creature in the world, but it is what you asked for

MJT Net Support
[email protected]
[email protected]
That's what I did and it exited
This is what I have been using
Iffileexists>C:\LoanArchiveFiles\123455-TITLE.tif,continue,error
Label>continue
VBSTART
Function filetime (filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = f.DateLastModified
s = FormatDateTime(s,vbShortTime)
filetime = s
End Function
VBEND
Let>filetest=C:\LoanArchiveFiles\123455-TITLE.tif
VBEval>filetime("%filetest%"),createdtime
MDL>%createdtime%
Goto>EOF
Label>error
MDL>File dosen't exist
Label>EOF
When it runs it makes Macro Scheduler close. I have no idea as to why I have tried all different things but it still dosen't want to work for me.
Iffileexists>C:\LoanArchiveFiles\123455-TITLE.tif,continue,error
Label>continue
VBSTART
Function filetime (filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = f.DateLastModified
s = FormatDateTime(s,vbShortTime)
filetime = s
End Function
VBEND
Let>filetest=C:\LoanArchiveFiles\123455-TITLE.tif
VBEval>filetime("%filetest%"),createdtime
MDL>%createdtime%
Goto>EOF
Label>error
MDL>File dosen't exist
Label>EOF
When it runs it makes Macro Scheduler close. I have no idea as to why I have tried all different things but it still dosen't want to work for me.
Your script runs fine here. Can't understand why Macro Scheduler would close. Which exact version are you running (see under Help/About).
MJT Net Support
[email protected]
[email protected]
Version
I am running version 7.3.11.1
I have tried rebooting and executing the script again and the same thing. I really don't get it. Especially because Macro Scheduler just closes, no error message or anything. I tried compiling the script and it would run and close, never bringing up the message box.
This VB Script works
Let>filedate1=05/05/2005 11:25 AM
Let>filedate2=05/05/2005 11:22 AM
VBStart
VBEnd
VbEval>(DateDiff("n","%filedate1%","%filedate2%")),TimeSpan
MDL>%TimeSpan%
I was planning on getting the file time and date with the other script and passing it on. I really don't get it.
I have tried rebooting and executing the script again and the same thing. I really don't get it. Especially because Macro Scheduler just closes, no error message or anything. I tried compiling the script and it would run and close, never bringing up the message box.
This VB Script works
Let>filedate1=05/05/2005 11:25 AM
Let>filedate2=05/05/2005 11:22 AM
VBStart
VBEnd
VbEval>(DateDiff("n","%filedate1%","%filedate2%")),TimeSpan
MDL>%TimeSpan%
I was planning on getting the file time and date with the other script and passing it on. I really don't get it.
Bad Install
I reinstalled Macro Scheduler and the script works. Once again it is not Macro Scheduler
This code uses the FileSystemObject so I'm thinking you have a DLL mismatch with the Microsoft Scripting Runtimes. Try reinstalling VBScript. You'll find a link to the VBScript Engine at this page:
http://www.mjtnet.com/resources.htm
http://www.mjtnet.com/resources.htm
MJT Net Support
[email protected]
[email protected]