Jump to content

InetGet filename from source?


KamikazeXeX
 Share

Recommended Posts

Hiya all, I'm downloading some files with InetGet but the problem is I'd like to save the files with the source file name for each of the downloads, InetGet will download the url selected from the array depending on what argument is passed in, the problem is how do i get it to generate the filename from the source files filename?

Link to comment
Share on other sites

  • Moderators

Is the filename you're downloading not in the URL? (See, this is where posting your code would come in handy ;) )

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

The filename is in the URL but according to the wiki/online help you have to specify a file name, heres the InetGet download line

$dwnlink = InetGet($dwnarrayread[$link], @ScriptDir & "\Files\filename.zip", 1, 1)

$link is the argument passed in from the case switch depending on what download button has been pressed and depending on what button gets pressed the IniRead array interprets what link you've selected like this

Case $filesgui
            Switch $nmsg[0]
                Case $filelabel1
                    ;_downloader(0)
                Case $filelabel2
                    _downloader(1)
                Case $filelabel3
                    _downloader(2)
            EndSwitch

Its working fine to download but I need to get the source filename working as it overwrites the previously downloaded file due to having the same file name so as per my example URLS I'd like to find a way to have InetGet download the files as file1.zip file2.zip and file3.zip

example URLs array
[files_links]
link_1=http://somesite.com/files/file1.zip
link_2=http://somesite.com/files/file2.zip
link_3=http://somesite.com/files/file3.zip

another bizzare thing is my app automatically starts the download process as soon as its launched and it will loop the download over and over but at the same time the rest of the GUI doesn't function, if i comment out the case for button1 it works fine and i can download file 2 and 3 fine when moving into the download tab but button1 obviously does nothing

Link to comment
Share on other sites

Post your script, you're doing something wrong in it and we can't tell you what that is because we don't have any code.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

post your script if you want help

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Func _downloader($link)
    Local $dwnarrayread[3] = [IniRead(@ScriptDir & "\Files\data\Config.cfg", "file_links", "link_1", Default), IniRead(@ScriptDir & "\Files\data\Config.cfg", "file_links", "link_2", Default), IniRead(@ScriptDir & "\Files\data\Config.cfg", "file_links", "link_3", Default)]
    $dwnlink = InetGet($dwnarrayread[$link], @ScriptDir & "\Files\filename.zip", 1, 1)
    Do
        Sleep(50)
        $prc = Round(InetGetInfo($dwnlink, 0) / (InetGetInfo($dwnlink, 1)) * 100)
        GUICtrlSetData($progressbar1, $prc)
    Until InetGetInfo($dwnlink, $INET_DOWNLOADCOMPLETE)
EndFunc

Thats the downloader function, i just need to work out how to get the source filename from the ini as per my example posted below the.

[files_links]
link_1=http://somesite.com/files/file1.zip
link_2=http://somesite.com/files/file2.zip
link_3=http://somesite.com/files/file3.zip

http://somesite.com/files/"this part here.zip" <--------

Link to comment
Share on other sites

Is there a reason your using IniRead on a .cfg file? Can't be a .ini file? That could be your problem right there.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Its working fine, I've been able to read and write to it using iniRead and write, i'll change the extension but at the end of the day its a text file and should work just fine no matter what extension (within limits)

EDIT: as also previously mentioned it does download the intended files but they have the wrong names the contents is as it should be

Edited by KamikazeXeX
Link to comment
Share on other sites

Your creating what the name will be in the second parameter:

$dwnlink = InetGet($dwnarrayread[$link], @ScriptDir & "\Files\filename.zip", 1, 1)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...