bytedance-1 / hide_cache_contents.sh
drdata's picture
Upload folder using huggingface_hub
e4d97fa verified
#!/usr/bin/env zsh
set -euo pipefail
# hide_cache_contents.sh
# Hides all files and folders inside .cache except the Assets folder by setting
# the macOS `hidden` file flag (chflags hidden). Run with `--undo` to remove
# the hidden flag.
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
CACHE_DIR="$SCRIPT_DIR/.cache"
if [ ! -d "$CACHE_DIR" ]; then
echo ".cache directory not found at $CACHE_DIR"
exit 1
fi
ACTION="hide"
if [ "${1:-}" = "--undo" ]; then
ACTION="unhide"
fi
echo "Will $ACTION items in: $CACHE_DIR (preserving Assets)"
for entry in "$CACHE_DIR"/.* "$CACHE_DIR"/*; do
# skip nonexistent globs
[ -e "$entry" ] || continue
base=$(basename "$entry")
# skip current/parent
if [ "$base" = "." ] || [ "$base" = ".." ]; then
continue
fi
# always preserve Assets (do not hide it)
if [ "$base" = "Assets" ]; then
if [ "$ACTION" = "hide" ]; then
chflags nohidden "$entry" 2>/dev/null || true
else
chflags nohidden "$entry" 2>/dev/null || true
fi
continue
fi
if [ "$ACTION" = "hide" ]; then
chflags hidden "$entry" 2>/dev/null || true
else
chflags nohidden "$entry" 2>/dev/null || true
fi
done
echo "Done: $ACTION completed. Use '$0 --undo' to revert."