本帖最后由 batman 于 2011-6-1 21:50 编辑
vbs版(对应的是12位编码)- Dim oexcel, vbstr
- Set oexcel = CreateObject("excel.application")
- Set ws = CreateObject("wscript.shell")
- oexcel.Visible = False
- oexcel.Workbooks.Open(ws.CurrentDirectory & "\a.xls")
- i = 1
- Do Until oexcel.Cells(i, 1).value = ""
- For j = 1 To 2
- vbstr = vbstr & oexcel.Cells(i, j).value & "#"
- Next
- vbstr = vbstr & vbCrLf
- i = i + 1
- Loop
- oexcel.Workbooks.Close
- Set oexcel = Nothing
- Dim fso, filename, num, str
- Set fso = CreateObject("scripting.filesystemobject")
- For Each file In fso.GetFolder(ws.CurrentDirectory).Files
- If LCase(fso.GetExtensionName(file)) = "as" Then
- filename = Mid(file.Name, 7, Len(file.Name))
- num = Left(file.Name, 6)
- For Each str In Split(vbstr, vbCrLf)
- If str <> "" Then If num = Split(str, "#")(0) Then fso.MoveFile file, file.ParentFolder & "\" & Split(str, "#")(1) & filename
- Next
- End if
- Next
- Set fso = Nothing
- Set ws = Nothing
- MsgBox "ok"
复制代码
|