Created
October 5, 2025 19:19
-
-
Save alileza/59c60481aa19f7a821b063faf6af129e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Desktop organization script | |
| # Organizes files by type and month created | |
| DESKTOP="/Users/alirezayahya/Desktop" | |
| cd "$DESKTOP" | |
| echo "Starting desktop organization..." | |
| # Create main organization directories | |
| mkdir -p "Organized/Screenshots" | |
| mkdir -p "Organized/Screen_Recordings" | |
| mkdir -p "Organized/Archives" | |
| mkdir -p "Organized/Documents" | |
| mkdir -p "Organized/Others" | |
| # Function to get month-year from file | |
| get_month_year() { | |
| file="$1" | |
| # Get file creation date | |
| stat -f "%SB" -t "%Y-%m" "$file" | |
| } | |
| # Process Screenshots | |
| echo "Organizing screenshots..." | |
| for file in Screenshot*.png; do | |
| if [ -f "$file" ]; then | |
| month_year=$(get_month_year "$file") | |
| mkdir -p "Organized/Screenshots/$month_year" | |
| mv "$file" "Organized/Screenshots/$month_year/" | |
| echo " Moved $file to Screenshots/$month_year" | |
| fi | |
| done | |
| # Process Screen Recordings | |
| echo "Organizing screen recordings..." | |
| for file in "Screen Recording"*.mov; do | |
| if [ -f "$file" ]; then | |
| month_year=$(get_month_year "$file") | |
| mkdir -p "Organized/Screen_Recordings/$month_year" | |
| mv "$file" "Organized/Screen_Recordings/$month_year/" | |
| echo " Moved $file to Screen_Recordings/$month_year" | |
| fi | |
| done | |
| # Process ZIP files and archives | |
| echo "Organizing archives..." | |
| for file in *.zip *.tar *.gz *.7z; do | |
| if [ -f "$file" ]; then | |
| month_year=$(get_month_year "$file") | |
| mkdir -p "Organized/Archives/$month_year" | |
| mv "$file" "Organized/Archives/$month_year/" | |
| echo " Moved $file to Archives/$month_year" | |
| fi | |
| done | |
| # Process document files | |
| echo "Organizing documents..." | |
| for file in *.pdf *.doc *.docx *.txt *.md *.xlsx *.pptx; do | |
| if [ -f "$file" ]; then | |
| month_year=$(get_month_year "$file") | |
| mkdir -p "Organized/Documents/$month_year" | |
| mv "$file" "Organized/Documents/$month_year/" | |
| echo " Moved $file to Documents/$month_year" | |
| fi | |
| done | |
| # Move AWSDiagnostics folder | |
| if [ -d "AWSDiagnostics_v3.9" ]; then | |
| echo "Moving AWSDiagnostics folder..." | |
| mv "AWSDiagnostics_v3.9" "Organized/Archives/" | |
| fi | |
| # Handle remaining files (excluding system files and this script) | |
| echo "Organizing other files..." | |
| for file in *; do | |
| # Skip system files, directories, and the organize script | |
| if [[ "$file" == ".DS_Store" ]] || [[ "$file" == ".localized" ]] || \ | |
| [[ "$file" == "Organized" ]] || [[ "$file" == "organize_desktop.sh" ]] || \ | |
| [ -d "$file" ]; then | |
| continue | |
| fi | |
| if [ -f "$file" ]; then | |
| month_year=$(get_month_year "$file") | |
| mkdir -p "Organized/Others/$month_year" | |
| mv "$file" "Organized/Others/$month_year/" | |
| echo " Moved $file to Others/$month_year" | |
| fi | |
| done | |
| echo "Desktop organization complete!" | |
| echo "" | |
| echo "Files have been organized into:" | |
| echo " - Organized/Screenshots/ (by month)" | |
| echo " - Organized/Screen_Recordings/ (by month)" | |
| echo " - Organized/Archives/ (by month)" | |
| echo " - Organized/Documents/ (by month)" | |
| echo " - Organized/Others/ (by month)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment