Last active
May 4, 2020 21:00
-
-
Save kastiglione/d17d715c2a4b398a9072576ea8874766 to your computer and use it in GitHub Desktop.
Change files to be transparently compressed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
hfs-compress() { | |
local files=("$@") | |
local filepath perms temppath | |
for filepath in "${files[@]}"; do | |
perms=$(stat -f %p "$filepath") | |
chmod +rw "$filepath" | |
temppath=$(mktemp) | |
ditto --hfsCompression "$filepath" "$temppath" | |
mv "$temppath" "$filepath" | |
chmod "$perms" "$filepath" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment