Computing.Net > Forums > Programming > Compare two PST files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Compare two PST files

Reply to Message Icon

Name: AJ (by William Jimenez)
Date: October 31, 2008 at 05:09:22 Pacific
OS: Windows XP
CPU/Ram: Dell
Comment:

Hello All,

using batch command how can i test if a PST file in drive C:\temp is newer than same file on H:\Temp and then perform an task based up that.

Basically:

IF c:\temp\file.pst has a later modified date than h:\folder\file.pst DO xxxxx

Thank you.



Sponsored Link
Ads by Google

Response Number 1
Name: tlserver
Date: October 31, 2008 at 09:02:24 Pacific
Reply:

You can do this using vbScript quite easily.

save this in notepad as a .vbs file

Dim filesys, thefile, theFile2, createdate, createdate2
Set filesys = CreateObject("Scripting.FileSystemObject")
Set thefile = filesys.GetFile("path_to_file_1")
Set thefile2 = filesys.GetFile("path_to_file_2")
createdate = thefile.DateLastModified
createdate = replace(createdate,"/","")
createdate = replace(createdate," ","")
createdate = replace(createdate,":","")
createdate = replace(createdate,"AM","")
createdate = replace(createdate,"PM","")
createdate2 = thefile2.DateLastModified
createdate2 = replace(createdate2,"/","")
createdate2 = replace(createdate2," ","")
createdate2 = replace(createdate2,":","")
createdate2 = replace(createdate2,"AM","")
createdate2 = replace(createdate2,"PM","")
msgbox createdate & " " & createdate2
if createdate > createdate2 then
msgbox "file 2 is older than file 1"
else
msgbox "file 1 is older than file 2"
end if

The script will check both files, get the modified date of both of them, strip out all useless date characters and then compare the two numeric strings. I'm sure there's a better way to strip the date or simply return just the time portion of it but I havent used vbscript for a while now, vb.net has screwed my logic from old school vb!


0

Response Number 2
Name: AJ (by William Jimenez)
Date: October 31, 2008 at 09:08:07 Pacific
Reply:

This works awsome!!

Thanks tlserver


0

Response Number 3
Name: klint
Date: October 31, 2008 at 10:19:24 Pacific
Reply:

I don't think this works.

Suppose date1 = "11:00:00 AM"
and date2 = "10:00:00 PM"

Then after that VBScript strips out the colons and the PM/AM indicators, it will leave date2 < date1 which is wrong.


0

Response Number 4
Name: Razor2.3
Date: October 31, 2008 at 15:44:33 Pacific
Reply:

Indeed, klint. And I find it much too complex; why convert a number into a complex string, just to see which number is bigger? A better version would be:

Dim filesys, With  CreateObject("Scripting.FileSystemObject")
If .GetFile("path_to_file_1").DateLastModified > .GetFile("path_to_file_2").DateLastModified Then
msgbox "file 2 is older than file 1"
Else
msgbox "file 1 is older than file 2"
End If
End With


0

Response Number 5
Name: klint
Date: October 31, 2008 at 17:56:27 Pacific
Reply:

Thanks Razor. I wasn't sure if what you wrote was possible, because MSDN help doesn't say what the return type of DateLastModified actually is. It only shows example usage that treats it as a string.


0

Related Posts

See More



Response Number 6
Name: AJ (by William Jimenez)
Date: November 3, 2008 at 06:59:12 Pacific
Reply:

Hi guys thank you for all your help.

My issue is that I need to compare these two files from a bat file.

My batch script backs up a bunch of folders with robocopy and I know robocopy will exclude files if they are the same but I will elaborate so maybe there is a solution out there.

PST files can be very large and thus take several minutes to copy over a 100Mbps network. So let’s say user Jenny has say 4 PST files in C:\PSTs each one of them 1 GB in size accounting for the past 4 quarters of 2008. Jenny only opens 4th quarter in outlook and seldom opens the other files although she wants to keep them with her because from time to time she needs to go back.

Now my script checks if outlook is open if it is it will give the user a message (still batch here) telling them that Outlook will be shut down in order to backup her PST file. Outlook will automatically start back up when it is done. Now this could mean that she has to stop working and wait and wait for the 75 or so Mbps until all the modified PST are copied to the network drive.

To solve the wait issue I came up with the “great idea” of programmatically creating a C:\Temp folder copying the psts (at 400 to 600 Mbps) to the temp location and then start outlook and continue copying in the background, this way Jenny can continue working 70% faster than before.

The problem now is that because C:\temp is new robocopy will copy ALL the psts to the new location which is taking forever every single time.

If I could only test the following programmatically.

IF any file in C:\PST is newer than the file in G:\PST then copy the file(s) from C:\PST to C:\temp

Once the only file that has changed is copied to C:\temp start outlook and then copy C:\temp\*.pst to the network drive.

I KNOW I’M ASKING FOR A LOT


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Compare two PST files

Compare two text files with spaces www.computing.net/answers/programming/compare-two-text-files-with-spaces/19886.html

VB Script Compare two Text files for Duplicat www.computing.net/answers/programming/vb-script-compare-two-text-files-for-duplicat/20247.html

Compare two text files, output diff to 3rd www.computing.net/answers/programming/compare-two-text-files-output-diff-to-3rd/19516.html