Giulio Caccin
Giulio Caccin

Reputation: 3052

How to download an entire dropbox directory in powershell?

I've tried a simple:

wget https://www.dropbox.com/sh/dropboxStuff/dropboxStuff?dl=1 -O DirectoryName

But it's downloading a zip file.

Upvotes: 2

Views: 3275

Answers (2)

alroc
alroc

Reputation: 28174

To do this in one line with PowerShell 5's Expand-Archive cmdlet:

Invoke-WebRequest -Uri https://www.dropbox.com/sh/dropboxStuff/dropboxStuff?dl=1 -O temp.zip; Get-Item temp.zip | Expand-Archive -DestinationPath "FolderName"; Remove-Item temp.zip

You may be able to do it by piping Invoke-WebRequest to Expand-Archive with -PassThru but I haven't been able to make it work yet.

Upvotes: 2

Stefano.Maffullo
Stefano.Maffullo

Reputation: 841

In Powershell v5

Expand-Archive c:\a.zip -DestinationPath c:\a

To know your PS vesion

$PSVersionTable.PSVersion 

If you don't have PS v5

Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
    param([string]$zipfile, [string]$outpath)

    [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

Unzip "C:\a.zip" "C:\a"

Source: This Question

Upvotes: 3

Related Questions