Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Samir Ibrahim
  Where is Samir Ibrahim?
 Chekka
 Lebanon
 Samir Ibrahim
 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: 189185 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Wednesday, August 13, 2008 5:18:06 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.

CLEAR 
LOCAL lcSourceFolder, lcDestFolder, ldDateToCompare
lcSourceFolder = "c:\source"
lcDestFolder = "c:\dest"
ldDateToCompare = CTOD("01/01/2007")

=CopyFilesWithDateRange(lcSourceFolder,lcDestFolder,ldDateToCompare)

FUNCTION CopyFilesWithDateRange(tcFolderSource,tcFolderDestination,tDateTocompare)
	LOCAL objFso, oFiles, oFilesList,oFile
	objFso = CreateObject("Scripting.FileSystemObject")
	IF objfso.FolderExists(tcFolderSource) = .F. then
		MESSAGEBOX("Error in Source Folder",0+16,"Error")
		RETURN
	ENDIF
	IF objfso.FolderExists(tcFolderDestination) = .F. then
		MESSAGEBOX("Error in Destination",0+16,"Error")
		RETURN
	ENDIF
	oFiles = objFso.GetFolder(tcFolderSource)
	oFilesList = oFiles.Files
	FOR EACH oFile IN oFilesList
		*? oFile.Name , oFile.DateCreated , oFile.DateLastModified  Debug Info
		*? DTOT(tDateToCompare) >= oFile.DateLastModified           Debug Info
		IF DTOT(tDateToCompare) >= oFile.DateLastModified
		    objFso.CopyFile(lcSourceFolder+"\" + oFile.Name ,lcDestFolder+"\"+oFile.Name,.t.)
		ELSE
			** Condition is Not Valid, Do Something Else
		ENDIF
	ENDFOR 
ENDFUNC  


Samir R. Ibrahim
Good things Take time, Great things happend all at once.

My WebLog
My Website: www.cdcity.org

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