I made a vbscript to read list of downloadable links then strip the file name only for the title, then it writes the titles to text file with downloadable link on the bottom. problem is how can i strip file name for different hosts with more than 40 characters at start.i want it to automatically remove everything before the fourth "/". i already tried splitting from "/" but it adds it to arrays. I only want the file name.
Code:
Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile (".\" & "inlinks.txt", 1)
Set logStream = objFSO.OpenTextFile (".\" & "outlinks.txt", 8, True)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrU = Split(strNextLine , ",")
strO= Mid(arrU(0), 40 ,260) ' removes everything before the fourth / and max 260 chars
strF= Replace (strO, ".rar", "") ' removes extensions
logStream.writeline strF 'write file name
logStream.writeline arrU(0)' write download link
logStream.writeline
Loop
Code:
Would look like this
INPUT:
http://www.thisatest.com/file/00000001/Test-File_Name_1.rar
http://www.thisatest.com/file/00000002/Test-File_Name_2.rar
http://www.thisatest.com/file/00000003/Test-File_Name_3.rar
OUTPUT:
Test-File_Name_1
http://www.thisatest.com/file/00000001/Test-File_Name_1.rar
Test-File_Name_2
http://www.thisatest.com/file/00000002/Test-File_Name_2.rar
Test-File_Name_3
http://www.thisatest.com/file/00000003/Test-File_Name_3.rar
If did it with another host would look like this
INPUT:
http://www.thislinkislonger.com/file/00000000/Test-File_Name_0.rar
OUTPUT:
.com/file/00000000/Test-File_Name_0
file/00000000/Test-File_Name_0
00000000/Test-File_Name_0