1
0
Fork 0
pomodoro/bash_scripts/archive_cleanup.sh
2024-05-02 20:38:07 +03:00

12 lines
782 B
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "Удаление файлов и папок из каталогов проектов перед восстановлением архива."
echo "Отмена" && exit 0; # предохранитель
cd ..
# обходим все репозитории, расположенные на одном уровне с текущим
find .. -mindepth 1 -maxdepth 1 -type d | sort -r | while read -r dir; do
echo "Обработка: $dir"
# заходим в каталог, иначе пропускаем итерацию
cd "$dir" || continue
# удаляем вложенные файлы и папки кроме папок '.git' и '.idea'
find . -mindepth 1 -maxdepth 1 -type f,d -not -name '.git' -not -name '.idea' -print0 | xargs -0 rm -r
done