Skip to content

Instantly share code, notes, and snippets.

@mattieb
Last active October 8, 2022 20:29
Show Gist options
  • Save mattieb/7bdaa5a16e4d5dc688848201d279a61b to your computer and use it in GitHub Desktop.
Save mattieb/7bdaa5a16e4d5dc688848201d279a61b to your computer and use it in GitHub Desktop.
finds all the undownloaded iCloud Drive files and downloads them
#!/bin/sh
#
# Finds all the undownloaded iCloud Drive files in the supplied
# path and uses brctl to download each one.
#
# This is a workaround for a problem I'm having trying to download
# directories full of undownloaded iCloud Drive files. Ideally, you'd
# just be able to run `brctl download PATH` and be done with it.
# (Try that first, actually.)
#
if [ "x$1" == x ]
then
echo usage: $0 PATH >&2
exit 1
fi
find "$1" -name .\*.icloud | grep -v '^\.Trash$' | (
while read fullpath
do
dir=$(dirname "${fullpath}")
file=$(basename -s .icloud "${fullpath}" | cut -c 2-)
echo ${fullpath} '=>' ${dir}/${file}
brctl download "${dir}/${file}"
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment