none
is possible to get file name from a url? RRS feed

  • Question

  • example

    var url="http://sample.com/test.jpg"

    i want to download the url with network.downloadfile but then i wnt to copy this file to test.jpg

    Sunday, July 15, 2018 7:48 PM

Answers

  • url = "http://sample.com/test.jpg"
    fName = LDFile.GetFile(url) +"."+ LDFile.GetExtension(url)
    TextWindow.WriteLine(fName)

    or a combination of methods from the 'Text' class, like:

    url = "http://sample.com/test.jpg"

    len = Text.GetLength(url) For n = len To 1 Step -1 If Text.GetSubText(url, n,1) = "/" Then fName = Text.GetSubTextToEnd(url, n+1) n = 1 ' ExitFor EndIf EndFor TextWindow.WriteLine(fName)




    Monday, July 16, 2018 2:36 PM
    Answerer

All replies

  • Use

    fil=Network.DownloadFile("http://sample.com/test.jpg") TextWindow.WriteLine(fil)

    File.CopyFile(fil,"Text.jpg")


    The variable "fil" then contains the name of the file where the download is saved. Then copy this file.

    This url gives an error 404, so you should use an URL which exists.


    Jan [ WhTurner ] The Netherlands

    Monday, July 16, 2018 11:32 AM
    Answerer
  • url = "http://sample.com/test.jpg"
    fName = LDFile.GetFile(url) +"."+ LDFile.GetExtension(url)
    TextWindow.WriteLine(fName)

    or a combination of methods from the 'Text' class, like:

    url = "http://sample.com/test.jpg"

    len = Text.GetLength(url) For n = len To 1 Step -1 If Text.GetSubText(url, n,1) = "/" Then fName = Text.GetSubTextToEnd(url, n+1) n = 1 ' ExitFor EndIf EndFor TextWindow.WriteLine(fName)




    Monday, July 16, 2018 2:36 PM
    Answerer