Skip to content

Instantly share code, notes, and snippets.

@alevgenk
Created March 30, 2017 11:00
Show Gist options
  • Save alevgenk/c4a89a967ce01ed2fcc197ac67e05be5 to your computer and use it in GitHub Desktop.
Save alevgenk/c4a89a967ce01ed2fcc197ac67e05be5 to your computer and use it in GitHub Desktop.
Dropbox exclude 'node_modules' bash script
#!/bin/bash
# based on https://gist.github.com/idleberg/6c8a563e248103baaa20
# SETTINGS
# ========
# Location of your Dropbox folder
dropbox_folder="/home/myname/Dropbox"
# Location of dropbox.py (http://www.dropboxwiki.com/tips-and-tricks/using-the-official-dropbox-command-line-interface-cli)
dropbox_script="/usr/bin/dropbox"
# Array of folders to ignore
ignore_list=['node_modules']
# FUNCTIONS
# =========
function recurse() {
for i in "$1"/*;do
if [ -d "$i" ];then
j=$(basename "$i")
if [[ " ${ignore_list[*]} " == *$j* ]]; then
command="$dropbox_script exclude add $i"
echo "Run $command";
$command
fi
recurse "$i"
fi
done
}
# SCRIPT
# ======
# Check Dropbox folder location
if [ -d "$dropbox_folder" ];then
echo "Dropbox found at $dropbox_folder"
else
echo "Dropbox not found"
exit 1
fi
# Check for dropbox.py
if [ -e "$dropbox_script" ];then
recurse $dropbox_folder
else
echo 'Aborted. See http://www.dropboxwiki.com/tips-and-tricks/using-the-official-dropbox-command-line-interface-cli#Installation for manual instructions.';
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment