Copy only new files

Copy only new files

Postby Marc Vanzegbroeck » Fri Sep 20, 2013 1: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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Copy only new files

Postby driessen » Fri Sep 20, 2013 2:11 pm

Maybe you could use this function :
Code: Select all  Expand view
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: Select all  Expand view
IF !FILE(cFile2) .OR. cDaTime(cFile1) > cDaTime(cFile2)
   CopyFile(...)
ENDIF
Good luck.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Copy only new files

Postby Marc Vanzegbroeck » 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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 22 guests