Apzo Posted July 24, 2006 Share Posted July 24, 2006 (edited) Hello ! I searched a way to easily backup my au3 scripts from work to home and vice versa. I found no (simple) equivalent to rsync on windows. So this is my attempt. It works "as is" and lets you choose friendly the source and destination directories, or with command line args. In case of command line mode, remember to enclose spaced paths with " Example : rsync "c:\documents and settings\me\my_folder" e:\ where e:\ is your USB storage key for example Rsync checks if a newer version of a file exists on both sides, and copy the newest at the right place. Rsync doesn't keep an history of your files as SVN would, so in case a file has been modified in the source AND destination, the newest will stay and the older will be overwritten. I hope this will help Apzo. [EDIT] Script updated, thanks to DMEE rsync.au3 Edited June 26, 2008 by Apzo All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
gamerman2360 Posted July 24, 2006 Share Posted July 24, 2006 Or you could start a new briefcase. I guess with this you don't have to drag and drop each file. Link to comment Share on other sites More sharing options...
Apzo Posted July 25, 2006 Author Share Posted July 25, 2006 No drag and drop needed, just select the 2 folders to synchonize and it's done Usefull when you work on a project at home and at work : just rsync your project on an USB key. I'm working on a net version using FTP, so you can allways get the latests files up to date anywhere. I'm thinking about a file history system, too. You would be able to set the number of backups for your files, and retrieve up to version-X if needed. No extra soft to install, just a standalone .exe : AU3 rocks Apzo. All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
FitzChivalry Posted January 29, 2007 Share Posted January 29, 2007 Hey Apzo, this is awesome. I work on my scripts at home and at work and it has always been a pain to figure out which ones are up to date. I'll start using this! thanks a bunch! Link to comment Share on other sites More sharing options...
krigaren Posted January 30, 2007 Share Posted January 30, 2007 Very useful script. Thanks for sharing. / K Link to comment Share on other sites More sharing options...
DMEE Posted June 26, 2008 Share Posted June 26, 2008 The script is really useful, but one small bug fix in your script would be changing: If StringRight($PathTo, 1) = "\" Then $PathFrom = StringTrimRight($PathTo, 1) EndIf In the beginning there was nothing and then even that exploded - anonymous Link to comment Share on other sites More sharing options...
Apzo Posted June 26, 2008 Author Share Posted June 26, 2008 You're right DMEE I've updated the script. Thanks !! Apzo. All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
laidback01 Posted July 18, 2008 Share Posted July 18, 2008 There is Microsoft's SyncToy. It works rather well for syncing files. Link to comment Share on other sites More sharing options...
kjcdude Posted September 12, 2008 Share Posted September 12, 2008 Perfect, just what i was looking for. Link to comment Share on other sites More sharing options...
rogdog Posted September 12, 2008 Share Posted September 12, 2008 Hello !I searched a way to easily backup my au3 scripts from work to home and vice versa.I found no (simple) equivalent to rsync on windows.'DeltaCopy' is a simple rsync tool for windows. Did you try that ? My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic] Link to comment Share on other sites More sharing options...
Bart74 Posted May 22, 2009 Share Posted May 22, 2009 (edited) Thanks for this excellent script. I have modified it to my own needs. I wanted to sync ppt files to a working directory, also the ones that do not exist in the source should be deleted. Also it should not copy any ppt file that is opened for edit. expandcollapse popupFunc Sync($from, $to, $ext, $withdelete) ; A modification from: ; http://www.autoitscript.com/forum/index.php?showtopic=29715 ; Building the logical source directory Local $returnVal = False Local $FilesFrom = FileFindFirstFile($from & "*." & $ext) While 1 Local $file = FileFindNextFile($FilesFrom) If @error Then ExitLoop ; Building the full path to source and destination file (or directory) Local $filename = FileGetLongName($from & $file) Local $tofilename = FileGetLongName($to & $file) ; Getting the mod. time of source and dest file... Local $fromtime = FileGetTime($filename, 0, 1) Local $totime = FileGetTime($tofilename, 0, 1) ; In case the destination file does not exists, $fromtime is always greater than $totime If $fromtime > $totime and not(FileLocked ($filename)) Then FileCopy($filename, $tofilename, 9) $returnVal = True EndIf WEnd ; Proper close of the file list FileClose($FilesFrom) ; If True, we should delete the files in the destination dir that do not exist in the source anymore If $withdelete Then Local $FilesTo = FileFindFirstFile($from & "*." & $ext) While 1 $file = FileFindFirstFile($FilesTo) If @error Then ExitLoop ; Building the full path to source and destination file (or directory) Local $filename = FileGetLongName($from & $file) Local $tofilename = FileGetLongName($to & $file) ;if the file in the from-dir does not exist, we should delete it in the dest-dir if not(FileExists ($fileName)) then FileDelete($tofileName) $returnVal = True EndIf WEnd FileClose($FilesTo) EndIf ; Return whether some copy/delete action took place return $returnVal EndFunc Func FileLocked ($fileName) ; Checks if a file is locked local $hFile = fileopen($fileName,1) Return $hFile <> -1 fileclose ($hFile) EndFunc Edited May 22, 2009 by Bart74 Link to comment Share on other sites More sharing options...
DrLove Posted May 24, 2009 Share Posted May 24, 2009 Works great! Is it possible to add a progressbar to the script?! Thanx Link to comment Share on other sites More sharing options...
Apzo Posted May 25, 2009 Author Share Posted May 25, 2009 Is it possible to add a progressbar to the script?! Everything is possible. BUT the _RSync func is recursive so it's a bit crappy. At the begenning, add : Global $FileCount Global $FileProg Before the 2 calls to func _RSync() add : Local $NbFilesFrom = DirGetSize($PathFrom, 1) Local $NbFilesTo = DirGetSize($PathTo, 1) If $NbFilesFrom[1] >= $NbFilesTo[1] Then ; Number of processed files = max($NbFilesFrom, $NbFilesTo) * 2, for 2 rsyncs are done $FileCount = $NbFilesFrom[1] * 2 Else $FileCount = $NbFilesTo[1] * 2 EndIf $FileProg = $FileCount ProgressOn("Rsync", "Synchronizing...") ; Let's go for a progress bar And just after, ProgressOff() of course. In the _RSync func, just before the WEnd, add : ProgressSet($FileProg*100/$FileCount, "Remaining : " & $FileProg) $FileProg -= 1 And you're done Apzo. All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
DrLove Posted May 25, 2009 Share Posted May 25, 2009 Everything is possible. BUT the _RSync func is recursive so it's a bit crappy. At the begenning, add : Global $FileCount Global $FileProg Before the 2 calls to func _RSync() add : Local $NbFilesFrom = DirGetSize($PathFrom, 1) Local $NbFilesTo = DirGetSize($PathTo, 1) If $NbFilesFrom[1] >= $NbFilesTo[1] Then ; Number of processed files = max($NbFilesFrom, $NbFilesTo) * 2, for 2 rsyncs are done $FileCount = $NbFilesFrom[1] * 2 Else $FileCount = $NbFilesTo[1] * 2 EndIf $FileProg = $FileCount ProgressOn("Rsync", "Synchronizing...") ; Let's go for a progress bar And just after, ProgressOff() of course. In the _RSync func, just before the WEnd, add : ProgressSet($FileProg*100/$FileCount, "Remaining : " & $FileProg) $FileProg -= 1 And you're done Apzo. Thanx, I'll try that. Link to comment Share on other sites More sharing options...
sliceofpie Posted August 13, 2010 Share Posted August 13, 2010 Everything is possible. BUT the _RSync func is recursive so it's a bit crappy. At the begenning, add : Global $FileCount Global $FileProg Before the 2 calls to func _RSync() add : Local $NbFilesFrom = DirGetSize($PathFrom, 1) Local $NbFilesTo = DirGetSize($PathTo, 1) If $NbFilesFrom[1] >= $NbFilesTo[1] Then ; Number of processed files = max($NbFilesFrom, $NbFilesTo) * 2, for 2 rsyncs are done $FileCount = $NbFilesFrom[1] * 2 Else $FileCount = $NbFilesTo[1] * 2 EndIf $FileProg = $FileCount ProgressOn("Rsync", "Synchronizing...") ; Let's go for a progress bar And just after, ProgressOff() of course. In the _RSync func, just before the WEnd, add : ProgressSet($FileProg*100/$FileCount, "Remaining : " & $FileProg) $FileProg -= 1 And you're done Apzo. This works but the status bar goes backwards. It shows a 100% done, then goes down to zero. Link to comment Share on other sites More sharing options...
wehr Posted November 15, 2010 Share Posted November 15, 2010 I was wondering if there is a way to make this synchonize a local directory with a folder on a server via ftp. But i can't think of any ways to insert the FTP folder correctly. Any suggestions? Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 15, 2010 Share Posted November 15, 2010 If you want to use a commmand line utility - check out Robocopy - it came with a Microsoft Resource Kit awhile back but can be found online. It offers a 'mirror' file copy option. Link to comment Share on other sites More sharing options...
storme Posted November 16, 2010 Share Posted November 16, 2010 If you want to use a commmand line utility - check out Robocopy - it came with a Microsoft Resource Kit awhile back but can be found online. It offers a 'mirror' file copy option.If your interested in Robocopy you coudl check out my Robocopy function. it makes life a lot easier.http://www.autoitscript.com/forum/index.php?app=forums&module=forums§ion=findpost&pid=843922Good luckJohn Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
Apzo Posted November 16, 2010 Author Share Posted November 16, 2010 Another way to sync dirs is to use a GNU port for windows of the well-known unix command 'cp'. Check the -u option : cp --help ... -u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing I use it twice : source -> destination then destination -> source. Apzo. All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now