{"id":244135,"date":"2022-06-16T08:34:42","date_gmt":"2022-06-16T00:34:42","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=244135"},"modified":"2022-05-31T20:38:10","modified_gmt":"2022-05-31T12:38:10","slug":"vbs-copy-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/vbs-copy-linux.html","title":{"rendered":"\u7b80\u5355\u4ecb\u7ecdVBS\u6279\u91cf\u91cd\u547d\u540d\u6587\u4ef6\u5e76\u4e14\u64cd\u4f5c\u524d\u5907\u4efd\u539f\u6709\u6587\u4ef6"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86VBS\u6279\u91cf\u91cd\u547d\u540d\u6587\u4ef6\u5e76\u4e14\u64cd\u4f5c\u524d\u5907\u4efd\u539f\u6709\u6587\u4ef6,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u6838\u5fc3\u51fd\u6570<\/strong><\/span><\/div>\n '==========================================================================\r\n'\r\n' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0\r\n'\r\n' NAME: \r\n'\r\n' AUTHOR: Microsoft , Microsoft\r\n' DATE : 2014\/7\/9\r\n'\r\n' COMMENT: '\u6279\u91cf\u4fee\u6539\u6587\u4ef6\u5939\u4e0b\u5bf9\u5e94\u7684\u6240\u6709\u6587\u4ef6\u540d\r\n'\r\n'==========================================================================\r\n'\u9009\u62e9\u6211\u7684\u7535\u8111\u4f5c\u4e3a\u6839\u76ee\u5f55\uff0c\u6765\u9009\u62e9\u76ee\u5f55\r\nConst MY_COMPUTER = &H11&\r\nConst WINDOW_HANDLE = 0\r\nConst OPTIONS = 0\r\nSet objShell = CreateObject(\"Shell.Application\")\r\nSet objFolder = objShell.Namespace(MY_COMPUTER)\r\nSet objFolderItem = objFolder.Self\r\nstrPath = objFolderItem.Path\r\nSet objShell = CreateObject(\"Shell.Application\")\r\nSet objFolder = objShell.BrowseForFolder _\r\n(WINDOW_HANDLE, \"Select a folder:\", OPTIONS, strPath)\r\nIf objFolder Is Nothing Then\r\nWscript.Quit\r\nEnd If\r\nSet objFolderItem = objFolder.Self\r\nobjPath = objFolderItem.Path\r\n'MsgBox objFolderItem.name\r\n'===================================================================\r\n'\u9009\u62e9\u6307\u5b9a\u76d8\u7b26\u4e0b\u7684\u76ee\u5f55\r\n' Const WINDOW_HANDLE = 0\r\n' Const OPTIONS = 0\r\n' \r\n' Set objShell = CreateObject(\"Shell.Application\")\r\n' Set objFolder = objShell.BrowseForFolder _\r\n' (WINDOW_HANDLE, \"Select a folder:\", OPTIONS, \"C:\\\")\r\n' \r\n' If objFolder Is Nothing Then\r\n' Wscript.Quit\r\n' End If\r\n' \r\n' Set objFolderItem = objFolder.Self\r\n' objPath = objFolderItem.Path\r\n' \r\n' MsgBox objPath\r\n'=========================================================================\r\n'\u5b9a\u4e49\u53d8\u91cf\r\ndim file_path,prefix_name,suffix_name,repeat_name,repeat_edit\r\nDim OneLine,TwoLine,ThreeLine,FourLine,FiveLine\r\ni=0\r\ntest = createobject(\"Scripting.FileSystemObject\").GetFile(Wscript.ScriptFullName).ParentFolder.Path\r\n'Wscript.echo test\r\nfilepath=test&\"\\config.ini\"\r\n'WScript.Echo filepath\r\n' file_path = \"C:\\Users\\Administrator\\Desktop\\1\\music\"'\u76ee\u6807\u6587\u4ef6\u5939\u7684\u8def\u5f84\r\ndst_file_path=\"C:\\\"&objFolderItem.name&\"_bak\"\r\nfile_path=objPath\r\n'-----\u5f97\u5230\u6587\u4ef6\u5939\u8def\u5f84\uff0c\u4e14\u6253\u5f00\u914d\u7f6e\u6587\u4ef6\r\nSet fso = CreateObject(\"Scripting.FileSystemObject\") \r\nSet folder = fso.getfolder(file_path) \r\nSet fs = folder.files\r\nSet file=fso.OpenTextFile(filepath,1)\r\n'----------------\u5728\u64cd\u4f5c\u524d\uff0c\u5907\u4efd\u4e00\u4e0b\u539f\u6709\u7684\u6587\u4ef6\r\nfso.CopyFolder file_path,dst_file_path,True\r\n'----------------------------------\r\n'\u53d6\u51fa\u7b2c\u4e00\u884c\u4e2d\u7684\u4e24\u4e2a\u6570\r\nOneLine=file.ReadLine\r\nOneLineStr=Split(OneLine,\"=\")\r\nOneLineCount=UBound(split(OneLine,\"=\"))\r\nFor i1=0 To OneLineCount\r\n'WScript.Echo OneLineStr(i1)\r\nNext\r\n'-------------------------------------\r\n'\u53d6\u51fa\u7b2c\u4e8c\u884c\u4e2d\u7684\u4e24\u4e2a\u6570\r\nTwoLine=file.ReadLine\r\nTwoLineStr=Split(TwoLine,\"=\")\r\nTwoLineCount=UBound(split(TwoLine,\"=\"))\r\nFor i2=0 To TwoLineCount\r\n'WScript.Echo TwoLineStr(i2)\r\nNext\r\n'-------------------------------------------\r\n'\u53d6\u51fa\u7b2c\u4e09\u884c\u4e2d\u7684\u4e24\u4e2a\u6570\r\nThreeLine=file.ReadLine\r\nThreeLineStr=Split(ThreeLine,\"=\")\r\nThreeLineCount=UBound(split(ThreeLine,\"=\"))\r\nFor i3=0 To ThreeLineCount\r\n'WScript.Echo ThreeLineStr(i3)\r\nNext\r\n'-------------------------------------------\r\n'\u53d6\u51fa\u7b2c\u56db\u884c\u4e2d\u7684\u4e24\u4e2a\u6570\r\nFourLine=file.ReadLine\r\nFourLineStr=Split(FourLine,\"=\")\r\nFourLineCount=UBound(split(FourLine,\"=\"))\r\nFor i4=0 To FourLineCount\r\n'WScript.Echo FourLineStr(i4)\r\nNext\r\n'-----------------------------------------\r\n'\u53d6\u51fa\u7b2c\u4e94\u884c\u4e2d\u7684\u4e24\u4e2a\u6570\r\nFiveLine=file.ReadLine\r\nFiveLineStr=Split(FiveLine,\"=\")\r\nFiveLineCount=Ubound(split(FiveLine,\"=\"))\r\nFor i5=0 To FiveLineCount\r\n'WScript.Echo FiveLineStr(i5)\r\nNext\r\n'---------------------------------------------\r\n'\u8c03\u7528\u8fc7\u7a0b\r\n'Function_Main()\r\nFunction Function_Main()\r\nIf OneLineStr(1)=\"true\" Then\r\nFunction_Prefix_Name()\r\nElseif OneLineStr(1)=\"false\" Then\r\nFunction_Suffix_Name()\r\nElseif OneLineStr(1)=\"number\" Then \r\nFunction_Number_Value()\r\nElseif OneLineStr(1)=\"array\" Then \r\nFunction_MyArrayReName()\r\nElseif OneLineStr(1)=\"\" Then\r\nWScript.Quit\r\nEnd If\r\nEnd Function\r\n'-----------------------------------------\r\n'\u5728\u539f\u6709\u540d\u79f0\u524d\u589e\u52a0\u524d\u7f00\r\nFunction Function_Prefix_Name()\r\nFor Each file in fs\r\nFile.Name=TwoLineStr(1)&File.Name\r\nNext\r\nEnd Function\r\n'--------------------------------------\r\n'\u5728\u539f\u6709\u540d\u79f0\u524d\u589e\u52a0\u540e\u7f00\r\nFunction Function_Suffix_Name()\r\nFor Each file in fs\r\nName=Mid(file.name,1,instrrev(file.name,\".\")-1) '\u53d6\u5230.\u53f7\u524d\u9762\u7684\u6587\u4ef6\u540d\r\nFormat=Mid(file.name,instrrev(file.name,\".\")) '\u53d6\u5230.\u53f7\u540e\u9762\u7684\u540e\u7f00\u683c\u5f0f\r\nfile.Name=Name&ThreeLineStr(1)&Format\r\nNext\r\nEnd Function\r\n'--------------------------------------------\r\n'\u5728\u539f\u6709\u540d\u79f0\u524d\u589e\u52a0\u6709\u5e8f\u81ea\u589e\u6570\u5b57\r\nFunction Function_Number_Value()\r\nFor Each file In fs\r\nFourLineStr(1)=FourLineStr(1)+1\r\nfile.name=FourLineStr(1)&file.name\r\nNext\r\nEnd Function\r\n'Function_Suffix_Name()\r\n'--------------------------------------------------\r\n'\u6279\u91cf\u66f4\u6539\u6587\u4ef6\u540d\u79f0\r\nFunction Function_MyArrayReName()\r\nConst BeforAlarm=\"\u53d1\u751f\u72af\u4eba\u66b4\u72f1\uff0c\u8bf7\u6ce8\u610f\u89c2\u5bdf\"\r\nConst AfterAlarm=\"\u53d1\u751f\u72af\u4eba\u66b4\u72f1\uff0c\u5404\u5c0f\u7ec4\u6309\u9884\u6848\u5904\u7f6e\"\r\nDim MyArray(12)\r\nn=1\r\ny=0\r\nFor i=0 To 12\r\nIf i=11 Then\r\nMyArray(i)=\"\u76d1\u95e8\u54e8\"\r\nElseif i=12 Then\r\nMyArray(i)=\"\u81ea\u536b\u54e8\"\r\nElse\r\nMyArray(i)=n&\"\u53f7\u54e8\"\r\nn=n+1\r\nEnd If\r\n' WScript.Echo MyArray(i)\r\nNext\r\nFor Each file In fs\r\nFormat=Mid(file.name,instrrev(file.name,\".\")) \r\n'MsgBox Format\r\n'MsgBox MyArray(y)\r\nIf FiveLineStr(1)=\"before\" Then\r\nfile.name=MyArray(y)&BeforAlarm&Format\r\nElseif FiveLineStr(1)=\"after\" Then\r\nfile.name=MyArray(y)&AfterAlarm&Format\r\nElse\r\nMsgBox \"\u8bf7\u5148\u8bbe\u7f6e\u662f\u786e\u8ba4\u524d\u8fd8\u662f\u786e\u8ba4\u540e!\",,\"\u63d0\u793a\"\r\nWScript.Quit\r\nEnd If\r\ny=y+1\r\n'WScript.Echo file.name\r\nNext\r\nEnd Function\r\n \r\n'=======================================================================\r\n' If prefix_name <> \"\" then'\u6279\u91cf\u52a0\u524d\u7f00\r\n' For each f in fs\r\n' f.name = prefix_name&f.name\r\n' Next\r\n' End If\r\n' \r\n' if suffix_name <> \"\" then'\u6279\u91cf\u52a0\u540e\u7f00\r\n' For each f in fs\r\n' name = Mid(f.name,1,InstrRev(f.name,\".\")-1)\r\n' format = Mid(f.name,InstrRev(f.name,\".\"))\r\n' f.name = name & suffix_name & format\r\n' Next\r\n' end If\r\n' \r\n' if repeat_name <> \"\" then'\u6279\u91cf\u5220\u9664\u76f8\u540c\u5b57\u7b26\r\n' For each f in fs\r\n' On Error Resume Next \r\n' f.name = Replace(f.name,repeat_name,repeat_edit)\r\n' Next\r\n' end If\r\n' '-----\u6587\u4ef6\u64cd\u4f5c\u7ed3\u675f\r\n' \r\n' set fso = nothing'\u91ca\u653e\u5185\u5b58\r\n' \r\n' MsgBox(\"\u5b8c\u6210\uff01\")<\/pre>\n |