Last active
November 12, 2018 21:43
-
-
Save mimizone/dd1dd6565bd3fbff30314ae2a8349c28 to your computer and use it in GitHub Desktop.
cleanup duplicates in iTunes folder after consolidation crashed in the middle
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
#!/bin/bash | |
path=`pwd` | |
echo "processing $path" | |
echo "-------------------------------CHECKING FOLDERS-------------------------------" | |
# list the folders that are most likely duplicates | |
#remove " 1$", check a folder exists with that name, and delete | |
folders=`find . | egrep " 1$"` | |
while read -r f | |
do | |
# echo "... $f ..." | |
d=${f::${#f}-2} | |
if [ -d "$d" ]; then | |
echo "delete $d" | |
rm -r "$d" | |
fi | |
done <<< "$folders" | |
echo "-------------------------------CHECKING FILES-------------------------------" | |
# list files that are most likely duplicates | |
# remove " 1\.m..$", check a file exists with that name, and delete | |
files=`find . | egrep " 1\....$"` | |
while read -r f | |
do | |
# echo "... $f ..." | |
d=${f::${#f}-6}${f:${#f}-4:${#f}} | |
if [ -f "$d" ]; then | |
echo "delete $d" | |
rm -r "$d" | |
fi | |
done <<< "$files" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment