Sync software on your company's computer. vbs

Source: Internet
Author: User

05-06 years of writing things, put it up, do a backup bar, now look at that time to write code, still very normative.

Now, I would definitely write in JavaScript or Python.


Option Explicit '------------------------------------------------------------Description: For synchronizing directories and files in two directories '---------------

---------------------------------------------' const Strfoldera = "G:\Downloads\Soft" ' Const STRFOLDERB = ' K:\Soft ' Const STRFOLDERB = "G:\Downloads\Soft" Const Strfoldera = "K:\Soft" Dim fsoobj Set fsoobj = CreateObject ("Scripting.files Ystemobject ") If not Fsoobj.folderexists (Strfoldera) Then MsgBox (" Source Directory & Strfoldera & "does not exist. ") Else If not fsoobj.folderexists (strfolderb) Then Fsoobj.createfolder (strfolderb) Synchronize Strfoldera, Strfolderb E nd If Set fsoobj = Nothing MsgBox ("Congratulations, sync success.")     '------------------------------------------------------------' Description: Sync two folders ' parameters: ' sfoldera directory name ' Sfolderb Directory name ' return: No '------------------------------------------------------------Sub Synchronize (Sfoldera, Sfolderb) Dim Fsofoldera,fsofolderb Dim Fsosubfoldera, Fsosubfolderb Dim itmfoldera,itmfolderb Dim Fsofilea,fsofileb Dim ItmFileA,it Mfileb Dim BlnfileinfOlderb Dim blnfolderinfolderb Set fsofoldera = Fsoobj.getfolder (sfoldera) Set fsofolderb = Fsoobj.getfolder (SFolderB) Set Fsofilea = Fsofoldera.files Set Fsofileb = Fsofolderb.files for all Itmfilea in Fsofilea Blnfileinfolderb = Fal
			   Se for each itmfileb in Fsofileb If itmfilea.name = Itmfileb.name and _ Itmfilea.size = Itmfileb.size and _ itmfilea.datelastmodified = itmfileb.datelastmodified Then blnfileinfolderb = True Exit for end If Nex  T If not blnfileinfolderb Then itmfilea.copy fsofolderb.path & "\" & Itmfilea.name, True End If Next Set Fsofilea = Nothing Set Fsofileb = Nothing Set Fsosubfoldera = fsofoldera.subfolders Set Fsosubfolderb = fsofolderb.su Bfolders for each itmfoldera in Fsosubfoldera Blnfolderinfolderb = False for each itmfolderb in Fsosubfolderb If i Tmfoldera.name = itmfolderb.name Then blnfolderinfolderb = True Exit for-if Next if not blnfolderinfold ErB Then Fsoobj.creatEFolder (Fsofolderb.path & "\" & itmfoldera.name) End If Synchronize Itmfoldera.path, Replace (itmfoldera.path,s Trfoldera,strfolderb) Next Set Fsosubfoldera = Nothing Set Fsosubfolderb = no set Fsofoldera = Nothing Set fsof
 Olderb = Nothing End Sub


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.