Skip to content

Instantly share code, notes, and snippets.

@akfreas
Created February 23, 2017 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akfreas/b7690705b2aa2b27d1debcb41624f60f to your computer and use it in GitHub Desktop.
Save akfreas/b7690705b2aa2b27d1debcb41624f60f to your computer and use it in GitHub Desktop.
BACKUP_DIR='_backup';
FILE_LIST=`find . -type f -not -path "*$BACKUP_DIR*"`
mkdir -pv $BACKUP_DIR;
while IFS= read -r line
do
if [[ $line == *"$1"* ]]; then
newfile=`echo $line | sed "s%$1%$2%g"`;
mkdir -pv "`dirname "$newfile"`";
echo "Copying $line to $newfile";
cp "$line" "$newfile" 2> /dev/null;
mv "$line" $BACKUP_DIR 2> /dev/null;
fi;
list='\.png \.ttf';
if ! [[ " $list " =~ " $line " ]] ; then
LC_ALL=C sed -i '' "s%$1%$2%g" "$line";
fi
if [[ " $list " =~ " $line " ]] ; then
echo "$line matches $list";
fi
done <<< "$FILE_LIST";
#while IFS= read -r line
#do
# rm -rf $line;
#done <<< "$FILE_LIST";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment