FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Copy only new files
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Copy only new files
Posted: Fri Sep 20, 2013 01:41 PM

Hi,

I use copyfile() to copy files from one PC to another.
Now I want to change this by only copy the new files, and the existing files with a newer timestamp.
Is there an easy way to do this?
Now I make an arrat with al the files, and with a for next loop, copy the files.
I now I can first check if the file is new or newer, and add only those to my array, but I was wonder there was an option to to copyfile-function to copy only the new and newer files.

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Copy only new files
Posted: Fri Sep 20, 2013 02:11 PM
Maybe you could use this function :
Code (fw): Select all Collapse
STATIC FUNCTION cDaTime(cPathFile)

   LOCAL aDirectory := DIRECTORY(cPathFile)

RETURN(IF(EMPTY(aDirectory),SPACE(30),DTOS(aDirectory[1,3])+aDirectory[1,4]+STR(aDirectory[1,2],14,0)))
And then you can use this function this way :
Code (fw): Select all Collapse
IF !FILE(cFile2) .OR. cDaTime(cFile1) > cDaTime(cFile2)
   CopyFile(...)
ENDIF
Good luck.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Copy only new files
Posted: Sat Sep 21, 2013 12:00 PM

Michel,

Thank you for your response.

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite

Continue the discussion