本帖最后由 apang 于 2014-11-26 10:03 编辑
试试vbs- ''桌面文件夹路径
- strDesk = CreateObject("WScript.Shell").SpecialFolders("Desktop")
-
- Set objShell = CreateObject("Shell.Application")
- Set objFolder = objShell.Namespace(strDesk)
- ''快捷方式的目标文件路径
- strPath1 = objFolder.ParseName("周志.Lnk").GetLink.Path
- strPath2 = objFolder.ParseName("日志.Lnk").GetLink.Path
-
- Set fso = CreateObject("Scripting.FileSystemObject")
- ''读取目标文件内容
- txt1 = fso.OpenTextFile(strPath1, 1).ReadAll
- txt2 = fso.OpenTextFile(strPath2, 1).ReadAll
-
- ''建立正则表达式,替换文本内容
- Set re = New RegExp
- re.Pattern = "^ *(2)([\s\S]*?)(?=^ *()"
- re.MultiLine = True
- If Not re.Test(txt1 & vbCrLf & "(") Then WScript.Quit
- s = re.Execute(txt1 & vbCrLf & "(")(0).SubMatches(0)
- re.Pattern = "(3、).*(\n|$)"
- txt2 = re.Replace(txt2, "$1" & s)
- fso.OpenTextFile(strPath2, 2).Write txt2
复制代码
|