Переглянути джерело

Add delete temp files script

ApisNecros 2 роки тому
батько
коміт
93bacea628
1 змінених файлів з 50 додано та 0 видалено
  1. 50 0
      delete_temp_files

+ 50 - 0
delete_temp_files

@@ -0,0 +1,50 @@
+#!/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"