Skip to content

Instantly share code, notes, and snippets.

@rafacouto
Created November 11, 2015 14:43
Show Gist options
  • Save rafacouto/a327b754d810737d1cb7 to your computer and use it in GitHub Desktop.
Save rafacouto/a327b754d810737d1cb7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://github.com/prasmussen/gdrive
GDRIVE=/tmp/drive-linux-x64
# list of folders (review 'list' command)
LIST='18iT7rybp2MHlPvM3x0wYZTqA0A,2015:1Ua9MSA1CMGwEyoOxRyWd2xDREQ,2014:1NNP--HtjAsOg73cAVbV7pxT9Ng,2013:1t-fCxQMnJ6J9jghkgoay8itpFQ,2012:10I754WYiM6QbcAOtI3GB9ufRiA,2011:1DU_RkrXW09zqRB3eMx9dNAAWjg,2010:1OkOng3PvDhwAJOPYsPrQD1mpcA,2009:1nK7DH8hf4UaJ4ueasFHfEO-lqA,2008:1IIjYF5mtu42rNyuuV2mfl7aVew,2007'
IFS=':' read -ra DIRS <<< "$LIST"
for D in "${DIRS[@]}"; do
IFS=',' read -ra FIELDS <<< "$D"
ID=${FIELDS[0]}
YEAR=${FIELDS[1]}
echo "\\$YEAR\\"
mkdir $YEAR
cd $YEAR
for F in $($GDRIVE list --query "'$ID' in parents" | cut -f1 -d' ') ; do
[ $F == 'Id' ] && continue
echo -n "$F "
$GDRIVE download --force -i $F
done
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment