Created
October 8, 2022 20:57
-
-
Save mattieb/bc63c20166abab35522187e445568cea to your computer and use it in GitHub Desktop.
deletes files with the text " copy" in them if an original exists
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/sh | |
# | |
# Deletes files with the text " copy" in them if an original exists. | |
# Cleans up after me accidentally hitting duplicate across lots of | |
# nested folders. | |
# | |
if [ "x$1" == x ] | |
then | |
echo usage: $0 PATH >&2 | |
exit 1 | |
fi | |
find "$1" -name \*\ copy\* | ( | |
while read copy | |
do | |
orig=$(echo ${copy} | sed -e 's/ copy//') | |
if [ -f "${orig}" ] | |
then | |
echo found orig for ${copy} | |
rm "${copy}" | |
else | |
echo no orig for ${copy} | |
fi | |
done | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment