Skip to content

Instantly share code, notes, and snippets.

@xiconet
Created July 3, 2014 05:22
Show Gist options
  • Save xiconet/3296b8eb03ff1b3ae79a to your computer and use it in GitHub Desktop.
Save xiconet/3296b8eb03ff1b3ae79a to your computer and use it in GitHub Desktop.
gdsort: sort the output of gdrive list
#!/bin/sh
# sort the output of gdrive list
# takes a folder_id as argument, returns a sorted list of items in the corresponding folder
# TODO: sort by item title while keeping the id in the output
#
if [ $# = 0 ]; then
echo -e "you must provide a folder_id\nType -h or --help for details"
exit 0
fi
if [ $1 = "-h" ] || [ $1 = "--help" ]
then
echo -e "`basename $0` takes a folder_id and returns a sorted list \nfrom the output of \"gdrive list -q <folder_id>.\"\nUse \"root\" as an alias for the root's folder_id"
exit 0
fi
folder_id=$1
gdrive.exe list -n -q "'$folder_id' in parents" | sed -r 's/0B_.{26}//g' | sort
@xiconet
Copy link
Author

xiconet commented Jul 3, 2014

A little shell wrapper script around the excellent golang gdrive Google drive command-line client. A future (better) version would have the option to keep the Id column in the output. Also, it would be nice to have untruncated titles, but this depends on gdrive itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment