Skip to content

A self-automating bash script for organizing files on your Ubuntu-based Linux desktop into appropriate folders.

Notifications You must be signed in to change notification settings

IfGremlinThen/DesktopCleanup.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

DesktopCleanup.sh

A self-automating bash script for organizing files on your Ubuntu-based Linux desktop into appropriate folders.

Written in Bash 5.1. Edited in Atom 1.59. Tested on Linux Mint 21.2.

The purpose of this script is to perform general cleanup of your Desktop in a way that can be automated. As of Version 1.2, DesktopCleanup.sh schedules itself to run every 15 minutes as a crontab job.

DesktopCleanup.sh moves all files it recognizes into separate filetype-specific 'Unsorted' folders in each of your main Home folders (audio files will be moved to ~/Music/Unsorted, video will be moved to ~/Videos/Unsorted, etc). It also uses perl to bulk rename files with foreign characters found in MacOS filenames and ffmpeg to convert less popular lossy file formats into more universal and less lossy (or lossless) file formats. Below is a complete list of features:

Features

  • Automates itself as a crontab job to run every 15 minutes
  • Renames files with common foreign MacOS characters (requires perl)
  • Installs .otf & .ttf fonts to ~/.local/share/fonts
  • Converts (requires ffmpeg)
    • .avif, .bmp, .webp pictures to .png
    • .m4a & .mpga audio to .wav
    • .divx, .flv, .mov, .mpg, .webm video to .mp4
  • Moves
    • Applications
      • .deb, .flatpak, .flatpakref, .rpm packages to ~/Applications/Linux Packages
      • .appimage & .x86_64 apps to ~/Applications, makes them executable, and links them to the Desktop
      • .exe Windows apps to ~/Applications/Windows
      • .app MacOS apps to ~/Applications/MacOS
      • .apk Android apps to ~/Applications/Android
      • .xpi Mozilla Extensions to ~/Applications/Mozilla Extensions
    • Documents
      • .epub & .pdf books to ~/Documents/Books
      • .ctb, .doc, .rtf, .txt, .xlsx documents to ~/Documents/Unsorted
      • .html, .url webpages to ~/Documents/Webpages
    • Pictures
      • .kra, .psd, .xcf projects to _~/Pictures/Projects
      • "screenshots" to ~/Pictures/Unsorted/Screenshots
      • .gif, .jpg, .jpeg, .png, .raw, .svg, .tiff pictures to ~/Pictures/Unsorted
    • Music
      • .aiff, .flac, .mp3, .m4b, .ogg, .wav audio to ~/Music/Unsorted
      • .mid, .midi sheet music to ~/Music/Sheet Music
      • .sf2 soundfonts to ~/Music/Soundfonts
      • <1MB sound effects to ~/Music/SFX
    • Video
      • .flb, .kdenlive, .mlt, .osp, .ove, .xges projects to ~/Videos/Projects
      • .srt subtitles to ~/Videos/Subtitles
      • .3gp, .avi, .m4v, .mkv, .mp4, ogx videos to ~/Videos/Unsorted
    • Games
      • .swf Flash games to ~/Games/Flash
      • .nes NES roms to ~/Games/ROMs/Nintendo/NES
      • .smc & .sfc SNES roms to ~/Games/ROMs/Nintendo/SNES
      • .n64 & .z64 N64 roms to ~/Games/ROMs/Nintendo/N64
      • .gba GBA roms to ~/Games/ROMs/Nintendo/GBA
      • .nds DS roms to ~/Games/ROMs/Nintendo/DS
      • .3ds 3DS roms to ~/Games/ROMs/Nintendo/3DS
      • .ips, .rnqs romhacks to ~/Games/ROMs/Hacks
      • .sav, .srm, .oops save files to ~/Games/Save Files
      • .gblorb, .z3, .z5, .z8 text adventures to ~/Games/Text Adventures
      • .ydk decklists to ~/Games/TCGs
      • .scm & .scx Starcraft maps to ~/.wine/drive_c/Program Files (x86)/StarCraft/Maps
    • Downloads
      • .torrent torrents to ~/Downloads/Torrents
    • Miscellaneous
      • .m4p songs to ~/Desktop/Dangerous Files
      • .graffle, .icns, .numbers, to ~/Desktop/Unconvertable
  • Optional Moves: (can be enabled by removing the # from their function)
    • .applescript, .css, .html, .php, .py, .sh scripts to ~/Documents/Scripts
    • .7z, .rar, .tar.gz, .zip archives to ~/Documents/Unsorted Archives

Install optional dependencies on Debian/Ubuntu via apt:

sudo apt install ffmpeg perl

Installation

Installation is very simple, just drag-and-drop this script into your ~/Documents folder and run the following Terminal command:

bash ~/Documents/desktopcleanup.sh

Uninstallation

You can easily remove DesktopCleanup.sh from your system by trashing the .sh file in your ~/Documents folder and running the following Terminal command:

crontab -l | grep -v "desktopcleanup.sh" | crontab -

About

A self-automating bash script for organizing files on your Ubuntu-based Linux desktop into appropriate folders.

Topics

Resources

Stars

Watchers

Forks

Languages