/LinuxFileOrganizer

File organizer using Bash on Linux

Primary LanguageShell

LinuxFileOrganizer

This Bash script tackles the challenge of maintaining tidy directories by automatically sorting files based on their extensions.

Features❓

  • Takes a directory path as an argument.
  • Scans files within that directory.
  • Intelligently sorts files into subdirectories based on file extensions (e.g., .txt files go to a txt subdirectory).
  • Handles unknowns gracefully: Places files without extensions or with unknown types in a "misc" subdirectory.
  • Avoids duplication: If a subdirectory for a specific extension already exists, the script seamlessly moves files there.
  • Considers edge cases: Deals with files lacking extensions or starting with a dot (hidden files).

Getting Started 🚀

  • Save the script: Name it something descriptive, like organize_files.sh:
  • Make it executable: chmod +x organize_files.sh (run this command in your terminal) or chmod 777 organize_files.sh
  • Run the script: ./organize_files.sh /path/to/your/directory (replace with the actual directory path).

Commands to run it correctly

sudo touch organizer.sh
chmod 777 organizer.sh
code organizer.sh
./organizer.sh
./organizer.sh /bash/trash

f1 jpg f2 jpg f2