Page 1 of 1 1
Topic Options
#211527 - 2016-05-22 08:01 AM keep the most recent file
darphboubou Offline
Just in Town

Registered: 2016-05-22
Posts: 2
Loc: paris
Hi,

I tried to move some file between two folder. i use this command to do it:
MOVE "$src*.*" "$dst" /c /h /r

It's works fine. But the problem is when the file already exist on the destination folder, the destination file is overwrite by the source one".
I try to find how to keep the most recent file on the destination folder (if the source file is older than the destination one".

Could you help me?

regards

Top
#211528 - 2016-05-22 02:29 PM Re: keep the most recent file [Re: darphboubou]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
You would have to use dir() on the source with a loop and exist() with comparefiletimes() on the destination.

Or you could shell out to robocopy.
_________________________
!

download KiXnet

Top
#211529 - 2016-05-22 09:22 PM Re: keep the most recent file [Re: Lonkero]
darphboubou Offline
Just in Town

Registered: 2016-05-22
Posts: 2
Loc: paris
how can i use robocopy?
Top
#211530 - 2016-05-22 10:03 PM Re: keep the most recent file [Re: darphboubou]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Code:
shell "robocopy " + $source + " " + $destination + " /update"
or something close to that...
_________________________
!

download KiXnet

Top
#211531 - 2016-05-23 05:19 PM Re: keep the most recent file [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I believe you'll want to use the /XO switch (exclude older) with robocopy.
Top
#211532 - 2016-05-24 10:08 PM Re: keep the most recent file [Re: ShaneEP]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: CA
/s for sub-directories with files in them
/e for empty sub-directories too
/xo excludes older files (ie. only copy newer or updated files)
/xj eXclude Junction points (if you copy a user profile with links you'll spend a long time trying to remove the hundreds of duplicated folders) all my scripts use this switch as a mandatory switch since I don't use or need to copy junction links.

/R:n :: number of Retries on failed copies: default 1 million.
/W:n :: Wait time between retries: default is 30 seconds.

Example usage
robocopy "c:\test" "\\server\share\folder" /s /xo /xj /r:0 /w:0



Edited by NTDOC (2016-05-24 10:09 PM)

Top
#211533 - 2016-05-25 01:01 AM Re: keep the most recent file [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
The default retry value is silly. Gets me everytime
_________________________
!

download KiXnet

Top
#211540 - 2016-05-25 10:00 PM Re: keep the most recent file [Re: Lonkero]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: CA
It's designed to stay active in case the network connection has gone down so that it will continue if the network comes back up while you're away. For those not running it in service mode. At least that's what some guy from Microsoft said years ago.

Great program overall. Glad they chose to make it part of the OS install.

Top
#211542 - 2016-05-26 01:50 AM Re: keep the most recent file [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
From original NT reskits I only use kix and robocopy....
_________________________
!

download KiXnet

Top
#211560 - 2016-06-01 07:44 PM Re: keep the most recent file [Re: Lonkero]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: CA
Yeah, can't think of much else I use either.
Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 661 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org