Skip to content

Instantly share code, notes, and snippets.

@cpburnz
Last active May 30, 2022 14:46
Show Gist options
  • Save cpburnz/09a6faab161401840fc5b5fa08d88402 to your computer and use it in GitHub Desktop.
Save cpburnz/09a6faab161401840fc5b5fa08d88402 to your computer and use it in GitHub Desktop.
This script sets or removes the Dropbox ignored flag (the "com.dropbox.ignored" attribute) on a path.
#!/bin/sh
#
# This script sets or removes the Dropbox ignored flag (the
# "com.dropbox.ignored" attribute) on a path.
#
# Author: Caleb P. Burns
# License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# Version: 1.0.0
# Created: 2020-07-18
# Updated: 2020-07-18
#
if [ "$1" = '-h' ] || [ "$1" = '--help' ] || [ "$#" -lt 2 ]; then
echo "Usage: $0 [-h] { -s | -r } <path>"
echo
echo 'Set or remove the Dropbox ignored flag ("com.dropbox.ignored") on a path.'
echo
echo 'Arguments:'
echo ' -g <path> Get the flag from the file or directory path.'
echo ' -s <path> Set the flag of the file or directory path.'
echo ' -r <path> Remove the flag from the file or directory path.'
echo ' -h, --help Show this help message and exit.'
exit 1
fi
if [ "$1" = '-g' ]; then
attr -g com.dropbox.ignored "$2"
elif [ "$1" = '-s' ]; then
attr -s com.dropbox.ignored -V 1 "$2"
elif [ "$1" = '-r' ]; then
attr -r com.dropbox.ignored "$2"
else
echo "Invalid option: '$1'"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment