Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

determine if file changed

Posted on 2008-10-19
3
Medium Priority
?
174 Views
Last Modified: 2010-04-30
I am trying to create a file backup, but only want to overwrite files that have changed
How can i do this without using FSO ?
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 46

Accepted Solution

by:
aikimark earned 500 total points
ID: 22753884
you could use the file attribute to determine if the file has been modified and needs archiving.  to see this most easily, issue the following command:
DIR /AA

with XCOPY, this is the /A flag

========================
you can use the VB DIR() function to retrieve file names in a directory.  then you would concatenate the directory name and the file name as a parameter to the VB GetAttr() function.  see snippet example

Note:  If using the VB FileCopy statement, you will need to use the SetAttr statement to indicate you've created a backup.

strFilename = Dir(strPath & "*.*", vbNormal)
Do Until Len(strFilename) = 0
  FName = strPath & strFilename
  lngHasChanged = GetAttr(FName) And vbArchive
  If lngHasChanged = vbArchive Then
    ' create file backup
  End If
  strFilename = Dir
Loop

Open in new window

0
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 500 total points
ID: 22754034
Hi, isnoend2001.

You can use WMI.  A query like the one below will return all files that have their archive bit set.
On Error Resume Next
 
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
 
arrComputers = Array(".")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="
 
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile WHERE Archive='True'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
 
   For Each objItem In colItems
      WScript.Echo "AccessMask: " & objItem.AccessMask
      WScript.Echo "Archive: " & objItem.Archive
      WScript.Echo "Caption: " & objItem.Caption
      WScript.Echo "Compressed: " & objItem.Compressed
      WScript.Echo "CompressionMethod: " & objItem.CompressionMethod
      WScript.Echo "CreationClassName: " & objItem.CreationClassName
      WScript.Echo "CreationDate: " & WMIDateStringToDate(objItem.CreationDate)
      WScript.Echo "CSCreationClassName: " & objItem.CSCreationClassName
      WScript.Echo "CSName: " & objItem.CSName
      WScript.Echo "Description: " & objItem.Description
      WScript.Echo "Drive: " & objItem.Drive
      WScript.Echo "EightDotThreeFileName: " & objItem.EightDotThreeFileName
      WScript.Echo "Encrypted: " & objItem.Encrypted
      WScript.Echo "EncryptionMethod: " & objItem.EncryptionMethod
      WScript.Echo "Extension: " & objItem.Extension
      WScript.Echo "FileName: " & objItem.FileName
      WScript.Echo "FileSize: " & objItem.FileSize
      WScript.Echo "FileType: " & objItem.FileType
      WScript.Echo "FSCreationClassName: " & objItem.FSCreationClassName
      WScript.Echo "FSName: " & objItem.FSName
      WScript.Echo "Hidden: " & objItem.Hidden
      WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate)
      WScript.Echo "InUseCount: " & objItem.InUseCount
      WScript.Echo "LastAccessed: " & WMIDateStringToDate(objItem.LastAccessed)
      WScript.Echo "LastModified: " & WMIDateStringToDate(objItem.LastModified)
      WScript.Echo "Manufacturer: " & objItem.Manufacturer
      WScript.Echo "Name: " & objItem.Name
      WScript.Echo "Path: " & objItem.Path
      WScript.Echo "Readable: " & objItem.Readable
      WScript.Echo "Status: " & objItem.Status
      WScript.Echo "System: " & objItem.System
      WScript.Echo "Version: " & objItem.Version
      WScript.Echo "Writeable: " & objItem.Writeable
      WScript.Echo
   Next
Next

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 31507609
Thanks guys
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question