how to get the time stamp of a file?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
jennylci
Newbie
Posts: 14
Joined: Wed May 08, 2013 11:16 pm

how to get the time stamp of a file?

Post by jennylci » Wed May 08, 2013 11:28 pm

Hi all,

I'm a beginner of Macroscheduler and trying to find a way to get the time stamp of a file. I don't see any existing function can do it. Any suggestions? BTW, I tried to use VB code written by my friend, but it doesn't work in macroscheduler. The code looks like this:

vbstart

Function GetTimStamp(FileName)

Dim oFS As Object
Dim FileName As String
Dim mydate As String

Set oFS = CreateObject("Scripting.filesystemobject")

mydate = oFS.getfile(FileName).DateCreated
msgbox(mydate)

End Function
vbend

vbeval>GetTimeStamp("C:\TEMP\Test.txt")

This VB code give me this error message "VBScript compilation error:1025"
Please give me some advice, I've been struggle with this problem for a few days.... I'm not familiar with VB at all.

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu May 09, 2013 2:29 am

FileTime> will get the last modified time of a file. Here's a sample script that shows how you might use FileTime>, FileDate> and FileSize>.

Code: Select all

//Get a file to work with
GetFileList>%Script_Dir%\*.*,vFileList
Separate>vFileList,;,vFileName
Let>vFile=vFileName_1

//Get The Date, Time and Size of the file
FileDate>vFile,vFileDate
FileTime>vFile,vFileTime
FileSize>vFile,vFilesize


//Display the collected information
Let>vMessage=%vFile%%crlf%%Tab%%Tab%Size = %vFilesize%%crlf%
ConCat>vMessage,%Tab%%Tab%Date = %vFileDate%%crlf%
ConCat>vMessage,%Tab%%Tab%Time = %vFileTime%

MDL>vMessage

//If you want the date or time in a particular format you can use
//Midstr> to break it into parts and then put it together in
//your chosen format

MidStr>vFileDate,1,4,CCYY
MidStr>vFileDate,5,2,MM
MidStr>vFileDate,7,2,DD

Let>vFileDate=%MM%/%DD%/%CCYY%

Midstr>vFileTime,1,2,HH
Midstr>vFileTime,3,2,MN
Midstr>vFileTime,5,2,SS

Let>vFileTime=%HH%:%MN%:%SS%

Let>vMessage=%vFile%%crlf%%Tab%%Tab%Size = %vFilesize%%crlf%
ConCat>vMessage,%Tab%%Tab%Date = %vFileDate%%crlf%
ConCat>vMessage,%Tab%%Tab%Time = %vFileTime%

MDL>vMessage

jennylci
Newbie
Posts: 14
Joined: Wed May 08, 2013 11:16 pm

Post by jennylci » Fri May 10, 2013 6:41 pm

Thanks!!

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