# Set the folder where you want to save the books to
$dest = «C:\Documentos\libros\» # Make sure the file path ends in a \# Download the source list of books
$downLoadList = «http://ligman.me/2tk1D2V»
$bookList = Invoke-WebRequest $downLoadList# Convert the list to an array
[string[]]$books = «»
$books = $bookList.Content.Split(«`n»)

# Remove the first line – it’s not a book
$books = $books[1..($books.Length -1)]
$books # Here’s the list

# Get the total number of books we need to download
$bookCount = $($books).Count

# Set a simple counter to let the user know what book
# number we’re currently downloading
$currentBook = 0

# As an option, we can have it log progress to a file
$log = $true

if ($log -eq $true)

{

# Construct a log file name based on the date that
# we can save progress to
$dlStart = Get-Date
$dlStartDate = «$($dlStart.Year)-$($dlStart.Month)-$($dlStart.Day)»
$dlStartTime = «$($dlStart.Hour)-$($dlStart.Minute)-$($dlStart.Second)»
$logFile = «$($dest)BookDlLog-$dlStartDate-$dlStartTime.txt»

}

# Download the books
foreach ($book in $books)

{

# Increment current book number
$currentBook++
try

{

# Grab the header with the books full info
$hdr = Invoke-WebRequest $book -Method Head

# Get the title of the book from the header then
# make it a safe string (remove special characters)
$title = $hdr.BaseResponse.ResponseUri.Segments[-1]
$title = [uri]::UnescapeDataString($title)

# Construct the path to save the file to
$saveTo = $dest + $title

# If the file doesn’t exist, download it
if ($(Test-Path $saveTo) -eq $false)