How would i do a complete folder compare and copy difference in autoit
I have a folder out on a networkshare lets call it c
i want to copy all of its contents over to a computer i'm settings up and ONLY copy files to the computer that are not there or different on the networkshare.
so lets say i have c:\backup.bat on the networkshare
i want it to be the exact same on the new computer.
the exact same structure and and subdirectory structure should apply
i have something like this already in vb but it doesn't check for existance or differences.
If you have the latest version of AutoIT use the _FileListToArrayRec function (see AutoIT Help File for more info), I've used this quite extensively in the past. Here is an example of the code (note not tested).
#include <file.au3>;~ Get System Drive Letter for %SystemDrive% Enviroment Variable of local machine$_DIR_SYSDRIVE = EnvGet('SystemDrive');~ Get Server Share Name to copy contents from$_DIR_NETDRIVE = '\\mis\mis3\machines\' & @ComputerName & '\c';~ Create an Array (files/folders), including subdirectories, use relative path name i.e. Folder\Filename.exe$_ARR_SYSDRIVE = _FileListToArrayRec($_DIR_NETDRIVE, '*', 0, 1, 0, 1);~ Create an Array (files/folders), including subdirectories, use full path name i.e. \\mis\mis3\machines\ComputerName\c\Folder\Filename.exe ;~ Exit if no array is created from the shared network If @error = 1 Then Exit$_ARR_NETDRIVE = _FileListToArrayRec($_DIR_NETDRIVE, '*', 0, 1, 0, 2) ;~ Exit if no array is created from the shared network If @error = 1 Then Exit;~ Go through the full folder list and check that it doesn't exist on the local machine if not found copy the file and create the directory if necessary.For $x = 1 To $_ARR_NETDRIVE[0] If StringInStr($_ARR_NETDRIVE[$x], $_ARR_SYSDRIVE[$x]) And FileExists($_DIR_SYSDRIVE & '\' & $_ARR_SYSDRIVE[$x]) = 0 Then FileCopy($_ARR_NETDRIVE[$x], $_DIR_SYSDRIVE & '\' & $_ARR_SYSDRIVE[$x], 8) EndIfNext
matrixnz,
that makes sense and all but how would i check to see if it is new. not so much of exist thats a given.
I was thinking something like this maybe ?
stivoli,
i was looking at robocopy but i don't really understand how to make it check path1 against path2 and copy accordingly.
What my goal is to take and copy all the files on the share \\share\c to the root of the local machine
and only copy files that do not exist or are different on the \\share\c