· 2 min read

Kaggle CLI QA: How to download a particular folder


Harshini on Medium asks

Nice Article,

But I got struck while trying to download a particular folder from kaggle competition “state-farm-distracted-driver-detection”. I want to download “img/train/c4” folder in that dataset, But when I’m trying to run the command, it’s giving an error like “404 — Not found”..

But I am able to download a particular image like this “img/train/c2/img_100029.jpg”

*Is there any command to download a particular folder??

Hi Harshini,

Kaggle CLI does not support downloading the entire folder or multiple files at once (except in case of downloading entire competition). Only one file can be downloaded at a time via the CLI.

Here is how I downloaded the entire c4 folder

1. Created directory if it does not already exist

mkdir -p img/train/c4

2. Get the list of all files available in the dataset, filtered the files which were in the c4 folder, picked file name, repeatedly download each file.

kaggle competitions files -c state-farm-distracted-driver-detection | grep c4 | awk ‘{print $1}’ | while read x ; do kaggle competitions download -f $x state-farm-distracted-driver-detection -p img/train/c4 ; done

![]({{ site.baseurl }}/images/2020-03-10-hi-harshini/1.png)

— — — — —

I don’t use the command line regularly. These are the sources I looked:

kaggle competitions download -h

Hope this helps! Have a good day!

Medium reply

Back to Blog