Created
July 3, 2024 14:16
-
-
Save kyletimmermans/fd321c3ddae1fb5fe2b5214bc00f6bd4 to your computer and use it in GitHub Desktop.
Useful script to remove extra MacOS metadata files when moving files from MacOS to Linux. Also remove any Solidus characters (slash) from filenames which are allowed on Mac but not in Linux
This file contains 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
# Remove .DS_Store Files | |
find . -name ".DS_Store" -type f -delete | |
# Remove AppleDouble Files | |
find . -name '._*' -exec rm {} \; | |
# Change Any Illegal Solidus Chars in Filename to Fraction Slash | |
TARGET_CHAR=$(echo -ne '\xef\x80\xa2') | |
REPLACEMENT_CHAR="⁄" | |
find . -depth -name "*$TARGET_CHAR*" -print0 | while IFS= read -r -d '' file; do | |
new_file=$(echo "$file" | sed "s/$TARGET_CHAR/$REPLACEMENT_CHAR/g") | |
sudo mv "$file" "$new_file"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment