Jun 11, 2011

Map and synchronize a local directory and distant shared directory

Map a drive

To Map a distant shared folder or even a local one using Dos command prompt

Open a command prompt and lauch this command

For a local directory



subst Q: "C:\Documents and Settings\hb\"



For a shared directory on a different machine



subst z: "\\Shared Server\hb\My Documents"


Synchronize two folder

To do sync to folder , we will you a great command, that microsoft incorporated as an external command and it's the "xcopy" , I am pretty sure that microsoft bought the company that developped this tool ; as they did with the excel .
For more info on xcopy or the list of external command visit this site that i recommand to visit from time to time http://www.computerhope.com

now back to how to sync the folder ; you create a batch file let's call it sync.bat
and add those two line and xcopy will do every thing for you


xcopy "c:\localfolder" "q:\remotefolder" /S /Y /D
xcopy "q:\remotefolder""c:\localfolder" /S /Y /D



Run the batch file and tadah its a miracle ; the data of the two folder will be merged and they and folder will become an image for one another.

Scheduele automatic sync

Instead of manually running the sync.bat , we can ask the scheduler to execute it every day by using the at command for more information on the at command and some tweaks check this site : http://ss64.com/nt/at.html


at 00:10 /every:M,T,S sync.bat


but due to some user previleges problem as the local system runinng the scheduele don't have the rights to access a remote directory
use the graphical interface to add a task on the win scheduler

No comments: