#!/bin/bash WIN_USER="$(wslpath "$(cmd.exe /c "/dev/null)")" LOCAL="$WIN_USER/AppData/Local/Temp" ROAMING="$WIN_USER/AppData/Roaming" DOWNLOADS="$WIN_USER/Downloads/Temporary" cd "$LOCAL" echo "Deleting SSH agents" find ./ssh-* -maxdepth 1 -type d -mtime +1 2>/dev/null | while IFS= read -r dir do rm -r "$dir" done echo "Deleting Office temp files" find ./TCD* -maxdepth 1 -type d -mtime +5 2>/dev/null | while IFS= read -r dir do rm -r "$dir" done echo "Deleting MySQL Workbench files" find ./mysql-workbench-* -maxdepth 1 -type d -mtime +1 2>/dev/null | while IFS= read -r dir do rm -r "$dir" done echo "Deleting Google Chrome temp files" find ./chrome_drag* -maxdepth 1 -type d -mtime +2 2>/dev/null | while IFS= read -r dir do rm -r "$dir" done echo "Deleting go-build temp files" find ./go-build* -maxdepth 1 -type d -mtime +5 2>/dev/null | while IFS= read -r dir do rm -r "$dir" 2>/dev/null done echo "Deleting NodeJS Yarn temp files" find ./yarn--* -maxdepth 1 -type d -mtime +2 2>/dev/null | while IFS= read -r dir do rm -r "$dir" done echo "Deleting all other *.tmp files" find ./*.tmp -maxdepth 1 -mtime +2 -delete 2>/dev/null find -regextype posix-extended -regex "^\.\/\{[0-9A-F\-]{36}\}" -mtime +7 -delete 2>/dev/null echo "Deleting month-old temporary downloads" cd "$DOWNLOADS" find ./* -maxdepth 1 -mtime +30 -delete 2>/dev/null cd "$ROAMING" echo "Deleting VS Code caches older than 30 days" find ./Code/Cache/Cache_Data/* -type f -mtime +30 2>/dev/null | while IFS= read -r file do rm -f "$file" done find ./Code/CachedData/ -maxdepth 1 -type d -mtime +30 2>/dev/null | while IFS= read -r dir do rm -rf "$dir" done echo "Deleting DBeaver files" find ./DBeaverData/workspace6/General/Scripts/*.sql -size +1c -atime +7 -delete 2>/dev/null cd "$OLDPWD"