Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2011, 09:45 PM   PM User | #1
mileka
New to the CF scene

 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mileka is an unknown quantity at this point
Question help with url to filename vbscript

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
mileka is offline   Reply With Quote
Reply

Bookmarks

Tags
filehost, filename, url, vbscript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:15 PM.


Advertisement
Log in to turn off these ads.