Sign in to follow this  
Followers 0
xuzo

How to use InetGet to ftp download whole directories and not single files?

4 posts in this topic

How to download all files in a folder or the whole folder in one shot?

InetGet("ftp://ibiblio.org/pub/multimedia/mutopia/BachJS/BWV16/Cantata_16_no_5/", @TempDir & "Cantata_16_no_5-a4-pdfs.zip", 1)

This works fine file by file. I tried and failed this for all zip files:

InetGet("ftp://ibiblio.org/pub/multimedia/mutopia/BachJS/BWV16/Cantata_16_no_5/", @TempDir & "*.zip", 1)

and failed also for all files:

InetGet("ftp://ibiblio.org/pub/multimedia/mutopia/BachJS/BWV16/Cantata_16_no_5/", @TempDir & "*.*", 1)

Thanks

Share this post


Link to post
Share on other sites



First of all, you cannot take a bunch of separate files on a website and download them as a single zip file. However, you can open the page, get a list of all the links and download them. For my example below, I made it check if the link has an extension. If it does not have an extension, then it is leading to a different directory, so it won't attempt to download something that is not there.

#include <File.au3>
#include <Array.au3>
#include <IE.au3>

Global $tempLink, $drive, $dir, $file, $ext
Local $oIE = _IECreate("ftp://ibiblio.org/pub/multimedia/mutopia/BachJS/BWV16/Cantata_16_no_5/")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended

DirCreate(@DesktopDir & "\Downloads")

For $oLink In $oLinks
$tempLink = $oLink.href
_PathSplit($tempLink, $drive, $dir, $file, $ext)
If $ext <> "" Then
Inetget ($tempLink, @DesktopDir & "\Downloads\" & $file & "." & $ext)
EndIf
Next
2 people like this

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi Nsfw,

This worked 100% perfectly on first try. Should be added to examples in help files actually!

Cheers!

Edited by xuzo

Share this post


Link to post
Share on other sites

guys,

awesome piece of code. however i can see 2 things when I executed.

1. 

Inetget ($tempLink, @DesktopDir & "\Downloads\" & $file & "." & $ext)

here $ext already holds the extn with a preceding ".", such as ".zip", so no need to add another extra &"."& in front of it.

2. I needed to download some .gz files from a public server so i tried to twik the code and run accordingly. but for some reason it's doing everything else but not downloading the file. 

can someone help me with the code? I'll be grateful as i'm almost out of options here other than banging my head on the wall. :mad2:

#include <File.au3>
#include <Array.au3>
#include <IE.au3>

Global $tempLink, $drive, $dir, $file, $ext
Local $oIE = _IECreate("ftp://ftp.wwpdb.org/pub/pdb/data/structures/divided/pdb/00")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended

DirCreate("C:\Downloads")

For $oLink In $oLinks
$tempLink = $oLink.href
_PathSplit($tempLink, $drive, $dir, $file, $ext)
If $ext <> "" Then
ConsoleWrite("in: "&$tempLink&@CRLF&$drive&@CRLF&$dir&@CRLF&$file&@CRLF&$ext&@CRLF)
Inetget ($tempLink, "C:\Downloads\" & $file &  $ext)
ConsoleWrite("out: "&"C:\Downloads\" & $file & $ext&@CRLF)
EndIf
Next
_IEQuit($oIE)

Thanks guys. I know you guys are pro's and I hope someone will be able to rescue me out of this.

Share this post


Link to post
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
Sign in to follow this  
Followers 0