Skip to content

Instantly share code, notes, and snippets.

@matayoshi
Created February 15, 2012 13:42
Show Gist options
  • Save matayoshi/1835738 to your computer and use it in GitHub Desktop.
Save matayoshi/1835738 to your computer and use it in GitHub Desktop.
Dropbox のキャッシュを削除するシェルスクリプト
#!/bin/sh
# Dropbox のキャッシュを削除するシェルスクリプト
# Ver.1.0.0 2011/08/17
# Ver.1.1.0 2011/11/29
# Ver.1.2.0 2012/02/15
# キャッシュフォルダのパスを取得
dropbox_folder=$(sqlite3 "${HOME}/.dropbox/config.db" "select value from config where key = 'dropbox_path';")
if [ -z $dropbox_folder ] || [ ! -d $dropbox_folder ] ; then
dropbox_folder=$(head -n 2 "${HOME}/.dropbox/host.db" | tail -n 1 | base64 -d)
fi
cache_folder="${dropbox_folder}/.dropbox.cache"
echo "DropBox Cache folder: ${cache_folder}"
echo
echo "Cache file(s) Deleting..."
if [ $(ls "${HOME}/.dropbox/l" | wc -l) -gt 0 ] ; then
for i in "${HOME}/.dropbox/l"/*
do
echo ${i}
rm "${i}" 2> /dev/null
done
fi
if [ $(ls "${cache_folder}" | wc -l) -gt 0 ] ; then
for i in "${cache_folder}"/*
do
echo ${i}
for j in "${i}"/*
do
echo ${j}
rm "${j}" 2> /dev/null
done
rmdir "${i}" 2> /dev/null
done
fi
echo
echo "file(s) Delete Completed!"
# 変数開放
cache_folder=
dropbox_folder=
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment