command line to copy files from dir A to B but skip existing ones


  1. Posts : 11,247
    Windows / Linux : Arch Linux
       #1

    command line to copy files from dir A to B but skip existing ones


    Hi there

    Is there a Windows command that can copy files from say directory A to directory B but skip any with the same name I don't want to update even if say directory A has a newer version than directory B --simply use existing names --if it exists skip.

    I'm trying to replicate the Linux command :

    rsync -a -v --ignore-existing <src> <dst> where src is source directory and dst is destination / target directory (or device etc)

    (This command also has options to OVERWITE target directory with newer file -- I don't want that option yet - the example I gave will ignore existing files if they already exist in the target directory. Note also - this doesn't CARE what's in the files - it's purely on the NAME - no dates / attributes /size etc considerations are checked - simply the NAME - which is why this job can be lightning fast even for quite a lot of files.

    What I'm trying to do is automate sending files to a NAS server every so often (say once a day / week) from WINDOWS clients when new files have been created --I don't need to backup all the windows clients - users can do that themselves - There's a job on the Clients that can backup / restore their desktop in entirety which is run on demand.

    Any ideas --shouldn't be too hard but I don't really know too much of Windows possibilities from the CLI.

    Note I don't want a GUI --need a command as this will be (eventually) an automated background process on the Windows clients.

    I did see there's an experimental Bash interface - but putting that in the hands of inexperienced users would probably be a recipe for DISASTER !!!.

    Cheers
    jimbo
      My Computer


  2. Posts : 4,201
    Windows 10 Pro x64 Latest RP
       #2

    SyncToy is the app that comes to mind - If it's still available. Not command line but simple GUI

    What I've done in the past is create backup/update/copy routines until they are reliable and fine tuned to meet all eventualities then create a shortcut for each, (option is included in software), and this is all the user gets access to

    Download SyncToy 2.1 from Official Microsoft Download Center

    There is the robocopy command which may be of use if you have to use command line Try robocopy /?
      My Computers


  3. Posts : 11,247
    Windows / Linux : Arch Linux
    Thread Starter
       #3

    Barman58 said:
    SyncToy is the app that comes to mind - If it's still available. Not command line but simple GUI

    What I've done in the past is create backup/update/copy routines until they are reliable and fine tuned to meet all eventualities then create a shortcut for each, (option is included in software), and this is all the user gets access to

    Download SyncToy 2.1 from Official Microsoft Download Center
    Hi there

    Thanks for the suggestion -- looks good and probably best on offer - however I'm really trying to get a 100% background batch job to run --want it to be as automatic and as "user-proof" as possible.

    Thanks again for suggestion anyway as that program is good for other things too.

    I've had problems with Robocopy in the past --- could also be my fault (always RTFM !!!!!) but I might also give it another go.

    rsync is really good though if you use it properly --btw you must add a / to the end of the first directory in the source command or it will copy the WHOLE directory into the target -- e.g A will become A.A !!!! where A is within A.

    Cheers
    jimbo
      My Computer


  4. Posts : 4,201
    Windows 10 Pro x64 Latest RP
       #4

    Did you see my edit on Robocopy? It's not something I use but others swear by it. you could also use the shortcut data from Synctoy to use it inside a batch
      My Computers


  5. Posts : 11,247
    Windows / Linux : Arch Linux
    Thread Starter
       #5

    Barman58 said:
    Did you see my edit on Robocopy? It's not something I use but others swear by it. you could also use the shortcut data from Synctoy to use it inside a batch
    Hi there.

    @Barman58

    The Robocopy scheme works -thanks --but :

    Robocopy doesn't seem have an option to ignore date / timestamp on output directory -- it says ignore if source older than dest OR ignore if source newer than dest. Not sure if you can combine these !!

    I'm trying to make 2 scenarios -- copy so long as file doesn't exist on target (any date), or copy regardless --i.e overwrite target if it exists.

    The users want to have a choice -- sometimes when copying files they are working on something and don't want the original to be overwritten. I know you can encourage them to create a new file until they've finished with their changes --but have you ever tried "Educating Users" !!!!!!!

    Pity Files don't have a thing like the IBM mainframes did where you had "generation" names automatically generated such as file_name(0), file_name(-1), file_name(+1) etc. !!

    Cheers
    jimbo
      My Computer


  6. Posts : 4,201
    Windows 10 Pro x64 Latest RP
       #6

    You may be able to create two, (or several), different variations to overwrite or not, and create, and present, Short-cuts to the user, or probably, better for you, create a command line instruction from the shortcut to add to the batch files
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:37.
Find Us




Windows 10 Forums