实现原理:
1、批量下载.ts文件到系统文件夹,
2、不破坏文件命名规则-重命名,并保存在一个INT数组
如:我下载的文件名都是:
191925499348-3_3990_16.ts
191925499348-3_3989_17.ts
191925499348-3_3968_18.ts
191925499348-3_3968_19.ts
191925499348-3_3968_X.ts
前面是一个数字串的规则我们不管。一会我们重命名的时候,只要记录尾数的序号。将尾数(16、17、18...存入数组)
3、生成COPY语句,TS文件由升序排列:copy /b 16.ts+17.ts+18.ts+19.ts+20.ts...
4、打开 CMD,复制语句执行。
Private Sub Form_Load()
Dim strDir$
Dim strFile$
Dim sPath$: sPath = "E:\迅雷下载\视频任务组_20210702_1129\"
Dim newPath$: newPath = "E:\迅雷下载\视频任务组_20210702_xyb\"
Dim fnamelst$
Dim Wjm() As String
strDir = Dir("E:\迅雷下载\视频任务组_20210702_1129\")
Dim firstRedim As Boolean
Do
If InStr(strDir, ".ts") > 0 Then
strFile = strFile & "+" & strDir
Dim fname$: fname = Split(strDir, ".")(0)
Dim newFname$
newFname$ = Right(fname, Len(fname) - InStrRev(fname, "_"))
Name sPath & fname & ".ts" As newPath & newFname & ".ts"
If Not firstRedim Then
ReDim Wjm(0): firstRedim = True
Else
ReDim Preserve Wjm(UBound(Wjm) + 1)
End If
Wjm(UBound(Wjm)) = newFname
fnamelst = fnamelst & newFname & ".ts" & "+"
End If
strDir = Dir
Loop While strDir <> ""
Dim i As Integer
Dim x As Integer
For i = 0 To UBound(Wjm)
For x = 0 To UBound(Wjm)
If Int(Wjm(x)) > Int(Wjm(i)) Then
Dim tmp$: tmp = Wjm(i)
Wjm(i) = Wjm(x)
Wjm(x) = tmp
End If
Next
Next
i = 0
fnamelst = ""
x = 0
For i = 0 To UBound(Wjm)
fnamelst = fnamelst & Wjm(i) & ".ts" & "+"
If i Mod 110 = 0 And i > 0 Then
Debug.Print "copy /b " & Left(fnamelst, Len(fnamelst) - 1) & " new" & x & ".ts"
fnamelst = ""
x = x + 1
End If
Next
End Sub