themax90 Posted November 22, 2005 Share Posted November 22, 2005 (edited) Here is my UDF that will extract the name of a path or url for copying, downloading, etc.... You can use like this: $URL = "http://www.google.com/index.htm" InetGet($URL, "C:\" & _ExtractName($URL), 1, 1) Hope you like enough to add into AutoIt's next beta! expandcollapse popup;=============================================================================== ; Function Name: _ExtractName() ; Description: Extracts a filename from a url or path for downloading/copying etc.... ; Sets @Error to -1 if error occurs, otherwise @Error = 0 ; Returns: ; %String% = Could Extract Filename (Success) ; 0 = No filename found (Failure) ; -1 = Invalid String/Path/URL (Failure) ; -2 = Unknown Error (Failure) ; ; Author(s): Max Gardner (AutoIt Smith) <king.of.all@comcast.net> ;=============================================================================== Func _ExtractName($String) Local $Path, $URL, $Filename, $FileCheck $Path = StringSplit($String, "\", 1) $URL = StringSplit($String, "/", 1) Select Case $Path[0] >= 2 ; Extract From Path SetError(0) $Filename = $Path[$Path[0]] $FileCheck = StringSplit($Filename, ".", 1) If $FileCheck[0] <= 1 Then SetError(-1) Return 0 EndIf SetError(0) Return $Filename Case $URL[0] >= 2 ; Extract From URL SetError(0) $Filename = $URL[$URL[0]] $FileCheck = StringSplit($Filename, ".", 1) If $FileCheck[0] <= 1 Then SetError(-1) Return 0 EndIf SetError(0) Return $Filename Case Else ; Invalid Path/URL SetError(-1) Return -1 EndSelect SetError(-1) Return -2 EndFunc ;==>_ExtractName AutoIt Smith P.S. FINE LXP I will fix it, even though this is basically useless and no body will use it. Fixed : Dim to Local Edited November 30, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
themax90 Posted November 23, 2005 Author Share Posted November 23, 2005 Nobodys even posting, do you all not like this? Link to comment Share on other sites More sharing options...
SlimShady Posted November 23, 2005 Share Posted November 23, 2005 Too simple. I already have a UDF like this one. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now