DATE/TIME Compare

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
prolZ
Newbie
Posts: 10
Joined: Sun Oct 24, 2004 4:29 pm

DATE/TIME Compare

Post by prolZ » Fri Jan 07, 2005 3:07 pm

Tach,

ich brauch mal eure Hilfe wieder einmal ;-)

Wenn ich zwei Dateien miteinander vergleichen möchte //aber auf garkeinen Fall ausgehend von der Dateigröße sondern von der Datei(DATUM/UHRZEIT). Wie stelle ich das am besten an.

Ist es möglich mit VBSKRIPT was zu entwerfen???

DANKE.....

NunGutVerona

Post by NunGutVerona » Sun Jan 09, 2005 9:33 pm

Deine Chancen steigen wenn du deine Anfragen auf Englisch stellst, da die Mehrheit der Nutzer hier in dieser Sprache kommuniziert.

Your question: DATE/TIME Compare (regarding a file)

Guess yes, VBScript makes sense. Keep in mind that there are different kind of dates used with a file: last access, modified, created.

prolZ
Newbie
Posts: 10
Joined: Sun Oct 24, 2004 4:29 pm

Using VBSkript under Macro Scheduler

Post by prolZ » Wed Jan 26, 2005 1:58 pm

Hello people,

i have an problem. My skript needs an vbskript code because for my snychronization between two files/folders i need the correct date/hour from each file.

It is simply an query!!!

But how can i write this in code??? Could you help me people???
I have no experience in vbskript under Macro Scheduler.....

my questions are:
- which vb function ??? If File Date > < xxxx then snychronize.........
- which typ of variable .... i think integer it's to long -32xxx up to +32xxx or long, double.....


Thank you four your answer....

dd

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Thu Jan 27, 2005 3:41 pm

Macro Scheduler has a built in command for obtaining the date:
FileDate>filename,result

Do a search in these forums, there have been similar examples (some posted by myself) to use vbscript with date mathmatics, and obtaining file properties (like the last modified time).

Type of variable? VBScript uses 'variant' types, which can contain different types (boolean, string, integer, etc). You don't need to specify the type when you declare and use a variable.

You can probably do what you're trying to do without any vbscript.

prolZ
Newbie
Posts: 10
Joined: Sun Oct 24, 2004 4:29 pm

VB Code in the Forum

Post by prolZ » Fri Jan 28, 2005 3:52 pm

Hello Captive,

could you tell me where i could find your posting!
Technical/Beginners?

Thanks.

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Sat Jan 29, 2005 1:01 am

Here's a basic example using just the date, obtained from the "FileDate" command. (Untested)
Let>MyDate=20050110
Let>MyPath=c:\temp\
Let>Target=c:\target\
GetFileList>%MyPath%*.*,files
Separate>files,;,file_names
Let>k=0
Repeat>k
Let>k=k+1
Let>filename=file_names_%k%
FileDate>%filename%,result
' The %result% contains the CREATED date in YYYYMMDD format
If>%result%%filename%,%target%
EndIf
Until>k,file_names_count


Using VBScript to get the "date created" field. Taken mostly from the vbcsript document:


VBSTART

Function GetFileCreatedInfo(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = f.DateCreated
' you could use s = f.DateLastAccessed
' or s = f.DateLastModified
GetFileCreatedInfo = s
End Function

VBEND


Then in the example above, instead of using "FileDate>", you could use something like:
VBEVAL>GetFileCreatedInfo("%filename%"),result

and adjust the "If", because %result% will look something like:
"2/27/2004 8:00:47 PM"
(You can tweak the function to make the result look exactly how you want to)

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Sat Jan 29, 2005 1:07 am

One thing I'd like to add (this whole thread doesn't seem like it belongs in the beginners section), is that VBScript can also obtain the whole list for you, and copy the files too. You could write a function where you simply specified the "Source", the "Target", and code the function so that any files older than ... say 24 hours, or 30 minutes, etc are copied.

prolZ
Newbie
Posts: 10
Joined: Sun Oct 24, 2004 4:29 pm

Post by prolZ » Sat Jan 29, 2005 1:25 am

Hello Captive,
Thank you for your fast answer!
I will try it out!

THX

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