Synchronize software on the company's computer. vbs

Source: Internet
Author: User

05 ~ Put up what I wrote in and make a backup. Now let's take a look at the code that I wrote at that time, which is still very standard.

Now, I will definitely write it in Javascript or Python.

Option explicit 'delimiter' Description: used to synchronize the directories and files in the two directories 'using 'const strfoldera = "G: \ downloads \ soft" 'const strfolderb = "K: \ soft "const strfolderb =" G: \ downloads \ soft "const strfoldera =" K: \ soft "dim fsoobjset fsoobj = Createobject (" scripting. fileSystemObject ") if not fsoobj. folderexists (strfoldera) Then MS Gbox ("Source directory" & strfoldera & "does not exist! ") Elseif not fsoobj. folderexists (strfolderb) Then fsoobj. createfolder (strfolderb) synchronize strfoldera, strfolderbend ifset fsoobj = nothingmsgbox (" congratulations, synchronization successful! ") 'Taobao' Description: Synchronize two folders. 'parameter: 'sfoldera directory name 'sfolderb directory name' returned: none of the 'Operation sub synchronize (sfoldera, sfolderb) dim fsofoldera, fsofolderbdim folder, extends itmfoldera, itmfolderbdim fsofilea, fsofilebdim itmfilea, itmfilebdim blnfileinfolderbdim blnfolderinfolderbset fsofoldera = fsoobj. getfolder (sfoldera) set fsofolderb = fsoobj. getfolder (sfolderb) set fsofilea = fsofoldera. filesset fsofileb = fsofolderb. filesfor each itmfilea in fsofileablnfileinfolderb = falsefor each itmfileb in fsofilebif itmfilea. name = itmfileb. name and _ itmfilea. size = itmfileb. size and _ itmfilea. datelastmodified = itmfileb. datelastmodified then blnfileinfolderb = true exit forend ifnextif not blnfileinfolderb thenitmfilea. copy fsofolderb. path & "\" & itmfilea. name, trueend ifnextset fsofilea = nothingset fsofileb = nothingset fsosubfoldera = fsofoldera. subfoldersset fsosubfolderb = fsofolderb. subfoldersfor each itmfoldera in fsosubfolderablnfolderinfolderb = falsefor each itmfolderb in fsosubfolderbif itmfoldera. name = itmfolderb. name thenblnfolderinfolderb = trueexit forend ifnextif not blnfolderinfolderb thenfsoobj. createfolder (fsofolderb. path & "\" & itmfoldera. name) end ifsynchronize itmfoldera. path, replace (itmfoldera. path, strfoldera, strfolderb) nextset fsosubfoldera = nothingset fsosubfolderb = nothingset fsofoldera = nothingset fsofolderb = nothingend 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.