Created
May 1, 2017 14:45
-
-
Save redolivedev/9e4d9209c5205e572782ae95ba59d107 to your computer and use it in GitHub Desktop.
Remove special characters that don't show up on smb shares
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
#!/usr/bin/env bash | |
find "$1" -depth -print0 | while IFS= read -r -d '' file; do | |
d="$( dirname "$file" )" | |
f="$( basename "$file" )" | |
new=$(sed "s/[<>:;\"/\\|?*]/-/g" <<< "$f") | |
if [ "$f" != "$new" ]; then | |
if [ -e "$d/$new" ]; then | |
echo "Notice: \"$new\" and \"$f\" both exist in "$d":" | |
ls -ld "$d/$new" "$d/$f" | |
else | |
echo "$file" | |
echo "MOVED '$file' TO '$d/$new'" >> ~/Desktop/log-remove-special-characters.txt | |
mv "$file" "$d/$new" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment