File time in minutes

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

File time in minutes

Post by kpassaur » Mon May 16, 2005 3:53 pm

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?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon May 16, 2005 4:03 pm

MJT Net Support
[email protected]

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Example didn't work

Post by kpassaur » Mon May 16, 2005 6:07 pm

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?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon May 16, 2005 6:20 pm

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 ;-)
MJT Net Support
[email protected]

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

That's what I did and it exited

Post by kpassaur » Mon May 16, 2005 6:28 pm

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.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon May 16, 2005 7:06 pm

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]

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Version

Post by kpassaur » Mon May 16, 2005 7:31 pm

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.

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Bad Install

Post by kpassaur » Mon May 16, 2005 7:59 pm

I reinstalled Macro Scheduler and the script works. Once again it is not Macro Scheduler

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon May 16, 2005 8:03 pm

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
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts