保存为bat,用记事本打开后会变成utf-8格式,“源”变成乱码,不知道是否传说中的“联通”问题- @echo off & setlocal enabledelayedexpansion
- for /f "tokens=*" %%a in (List.txt) do (
- set "str=%%a"
- if "!str:~,1!"=="{" (
- if "!str:~-1!"=="}" set "fd=!str:~1,-1!" & md "!fd!\" 2>nul
- ) else (
- for /f "tokens=1*delims=," %%b in ("!str!") do (
- set /a ".!fd!.%%b+=1"
- for %%d in (!fd!) do set "a=00!.%%d.%%b!"
- >>"!fd!\%%b.txt" echo,^<Entry^> ^<Title^>%%b_源!a:~-2!^</Title^> ^<Ref href = "%%c"/^> ^</Entry^>
- )
- )
- )
- pause
复制代码 vbs,保存为unicode格式好了- Set fso = Createobject("Scripting.FileSystemObject")
- Set dic = CreateObject("Scripting.Dictionary")
- Set file = fso.OpenTextFile("List.txt")
-
- Do Until file.AtEndOfStream
- strLine = Trim(file.ReadLine)
- If Left(strLine,1) = "{" and Right(strLine,1) = "}" Then
- strFD = Mid(strLine,2,Len(strLine)-2)
- If Not fso.FolderExists(strFD) Then
- fso.CreateFolder strFD
- End If
- ElseIf strLine <> "" Then
- strName = Left(strLine,InStr(strLine,",")-1)
- strUrl = Right(strLine,Len(strLine)-InStr(strLine,","))
- strKey = strFD & "\" & strName
- If dic.Exists(strKey) Then
- dic.Item(strKey) = dic.Item(strKey) + 1
- Else dic.Add strKey,101
- End If
- s = "_源" & Right(dic.Item(strKey),2)
- s = "<Entry> <Title>" & strName & s & "</Title> <Ref href = "
- s = s & chr(34) & strUrl & chr(34) &"/> </Entry>"
- fso.OpenTextFile(strKey & ".txt",8,true).WriteLine s
- End If
- Loop
复制代码
|