1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #!/bin/bash
- ####
- # For use in WSL
- # Deletes stale temp files from AppData and my downloads folder
- ####
- WIN_USER="$(wslpath "$(cmd.exe /c "<nul set /p=%UserProfile%" 2>/dev/null)")"
- LOCAL="$WIN_USER/AppData/Local/Temp"
- 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 all other *.tmp files"
- find ./*.tmp -maxdepth 1 -type f -mtime +2 -delete 2>/dev/null
- echo "Deleting month-old temporary downloads"
- cd "$DOWNLOADS"
- find ./* -maxdepth 1 -type f -mtime +30 -delete 2>/dev/null
- cd "$OLDPWD"
|