Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Yehuda Epstein
  Where is Yehuda Epstein?
 Monsey
 New York - United States
 Yehuda Epstein
 Tags
Subject: RE: Files modified date
Thread ID: 188996 Message ID: 189116 # Views: 3 # Ratings: 4
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Wednesday, August 13, 2008 12:55:38 PM         
   


> Hi to all,
> It is sad to hear about Ken. He succeeded in helping me & many others. May his help & patient be remembered.
>
> I currently need help if possible, regarding copying files from a directory with a modified date >= to a certain date. The question is how do I write code to identify which files in this directory are >= to that date. I am already familiar to an extant with ADIR, which enables me to pass a file's modified date to a variable, but in this case we deal with many files with different changing names, which the only common denominator is their modified date, among other files with a different modified date.
>
> Can anyone help?
> Thanks in advance.

This is what I have been using for myself to backup recent changes in my project:

*GetNewFiles.prg
*Author: Cetin Basoz
*Purpose: Copy prg,scx,vcx, ... files newer than a given date(time) to a backup folder
Lparameters tuDate, tcFrom, tcTo
tuDate = evl(m.tuDate,Date())
tcFrom = Addbs( evl(m.tcFrom,fullpath('')) )
tcTo   = Addbs( evl(m.tcTo,'c:\MyBackups_'+Ttoc(Datetime(),1)) )

* PRG,SCX,VCX,FRX
GetTree(m.tcFrom,'*.prg;*.sc?;*.vc?;*.fr?;',.T.)
AFields(aStruc)
Select 0
Create Cursor CopyList from array aStruc
Append From Dbf('FileList') for lastwrite >= m.tuDate

* Project,Menu and headers
GetTree(m.tcFrom,'*.pj*;*.mn*;*.h',.T.)
Select CopyList
Append From Dbf('FileList') for lastwrite >= m.tuDate

* Copy to target
Md (m.tcTo)
Scan
	m.lcMinPath = Sys(2014,Trim(FilePath-FileName))
	m.lcTargetFolder = JustPath(m.lcMinPath)
	If !Empty(m.lcTargetFolder) and !Directory(m.tcTo+m.lcTargetFolder)
		Md (m.tcTo+m.lcTargetFolder)
	EndIf
	Copy File (Trim(filepath-filename)) to ;
		(Addbs(m.tcTo+m.lcTargetFolder)+Trim(FileName))
EndScan

Function GetTree
  Lparameters tcStartDir,tcSkeleton,tlSubfolders
  Create Cursor filelist ;
    (filepath c(250), filename c(250), ;
    filesize i, fattr c(8), createtime T, lastacc T, lastwrite T)
  oFiler = Createobject('filer.fileutil')
  With oFiler
    .SearchPath = tcStartDir
    .Subfolder = tlSubfolders
    .SortBy = 5
    .SortDirection = 1
    .FileExpression = tcSkeleton
    .Find(0)
    For ix=1 To .Files.Count
      With .Files(ix)
        If !(Bittest(.Attr,4) And .Name = '.')
          Insert Into filelist ;
            (filepath, filename, filesize, fattr, createtime, lastacc, lastwrite)  ;
            values ;
            (.Path, .Name, .Size, Attr2Char(.Attr), ;
            Num2Time(.Datetime), Num2Time(.LastAccessTime), Num2Time(.LastWriteTime))
        Endif
      Endwith
    Endfor
    Return .Files.Count
  Endwith

Function Num2Time
  Lparameters tnFloat
  Return Dtot({^1899/12/30}+Int(tnFloat))+86400*(tnFloat-Int(tnFloat))

  *!*	#Define FILE_ATTRIBUTE_READONLY             0x00000001
  *!*	#Define FILE_ATTRIBUTE_HIDDEN               0x00000002
  *!*	#Define FILE_ATTRIBUTE_SYSTEM               0x00000004
  *!*	#Define FILE_ATTRIBUTE_DIRECTORY            0x00000010
  *!*	#Define FILE_ATTRIBUTE_ARCHIVE              0x00000020
  *!*	#Define FILE_ATTRIBUTE_ENCRYPTED            0x00000040
  *!*	#Define FILE_ATTRIBUTE_NORMAL               0x00000080

Function Attr2Char
  Lparameters tnAttr
  Return ;
    IIF(Bittest(tnAttr,0),'RO','RW')+;
    IIF(Bittest(tnAttr,1),'H','_')+;
    IIF(Bittest(tnAttr,2),'S','_')+;
    IIF(Bittest(tnAttr,4),'D','_')+;
    IIF(Bittest(tnAttr,5),'A','_')+;
    IIF(Bittest(tnAttr,6),'E','_')+;
    IIF(Bittest(tnAttr,7),'N','_')


Cetin Basoz

ENTIRE THREAD

Files modified date Posted by Yehuda Epstein @ 8/12/2008 10:05:37 PM
RE: Files modified date Posted by Yuri Rubinov @ 8/12/2008 10:17:55 PM
RE: Files modified date Posted by Yehuda Epstein @ 8/12/2008 11:21:40 PM
RE: Files modified date Posted by Yuri Rubinov @ 8/13/2008 2:20:14 AM
RE: Files modified date Posted by Yehuda Epstein @ 8/13/2008 5:35:12 PM
RE: Files modified date Posted by Yousfi Benameur @ 8/13/2008 12:22:04 AM
RE: Files modified date Posted by Cetin Basoz @ 8/13/2008 12:55:38 PM
RE: Files modified date Posted by tushar @ 8/13/2008 2:57:04 PM
RE: Files modified date Posted by Samir Ibrahim @ 8/13/2008 5:18:06 PM