Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$old_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ext-thumbnail_url is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
Scaricare file automaticamente con Powershell | IlSoftware.it

Scaricare file automaticamente con Powershell

Nel precedente articolo dedicato a Powershell abbiamo già visto come utilizzare questa shell avanzate, disponibile in tutte le più recenti versioni di Windows, per rinominare gruppi di file in un colpo solo (Come rinominare una serie di...

Nel precedente articolo dedicato a Powershell abbiamo già visto come utilizzare questa shell avanzate, disponibile in tutte le più recenti versioni di Windows, per rinominare gruppi di file in un colpo solo (Come rinominare una serie di file con Powershell).
Powershell, però, grazie alla sua invidiabile versatilità, può essere utilizzata per far fronte a molteplici ulteriori esigenze.

Un semplice script Powershell può essere ad esempio utilizzato per scaricare file automaticamente.

Si supponga di avere a disposizione una lunga lista di file da scaricare: per avviare i download automatici è possibile comportarsi così come segue:

1) Creare una nuova cartella e salvarvi un file .txt con la lista completa dei file da scaricare. Assegnare a tale file il nome files.txt.

2) Creare un nuovo file di testo ed incollarvi quanto segue:

$list = Get-Content $args
$clnt = New-Object System.Net.WebClient

foreach($url in $list)
{ 

		#Get the filename
		$filename = [System.IO.Path]::GetFileName($url)
		#Create the output path
		$file = [System.IO.Path]::Combine($pwd.Path, $filename)

		Write-Host -NoNewline "Download di ""$url""... "

	#Download the file using the WebClient
		$clnt.DownloadFile($url, $file)
		Write-Host "Download completato."
}

3) Salvare il file con il nome download_files.ps1

4) Digitare Powershell nella casella di ricerca di Windows e selezionare Windows Powershell dall’elenco.

5) Utilizzando il comando cd, portarsi all’interno della cartella contenente i file download_files.ps1 e files.txt.

6) Al prompt di Powershell digitare il comando:

.\download_files.ps1 files.txt

Scaricare file automaticamente con Powershell
7) Powershell, seguendo le indicazioni contenute nello script precedentemente riportato, provvederà a scaricare, uno per uno, tutti i file specificati in files.txt.

Ti consigliamo anche

Link copiato negli appunti