Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Windows Batch & Powershell & VBS Script: copy files from SourceFolder which don't exist in DestinationFolder

Hello experts,

I have:
-SourceFolder and DestinationFolder
I would like to copy files located in SourceFolder which don't exist in DestinationFolder.
What is the most straightforward approach to do this?
Windows batch through robocopy & Powershell or VBS ?

Thank you for your help.
Avatar of oBdA
oBdA

Definitely robocopy. Robocopy will by default skip files that already exist in the target (same name, same size, same date).
Start with this (works in PS and batch):
robocopy.exe "S:\ource\Folder" "T:\arget\Folder" *.* /e /r:0

Open in new window

Avatar of Luis Diaz

ASKER

Ok, thank you.
Possible to have .bat approach with variable declaration?
Thank you for your help.
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for those proposals.
If Folders contains space should I protect them with double quotes?
I always do, as in my comment.  Looks like oBdA did as well.


»bp
Not when setting the variables. The quotes are added in the final command line. Just do not add a trailing backslash to the folders.
^ +1


»bp
Noted, thank you very much for your help.
Tested and it works!
Thank you for your help.