i# Directory Cleanup Bash Script
This Bash script is designed to organize files in a specified directory by moving them into subdirectories based on their file extensions. It also dynamically creates subdirectories as needed.
- Executable file should be in the parent directory of the directory to be cleaned up.
-
Run the Script:
- Make the script executable:
chmod +x your_script_name.sh - Execute the script:
./your_script_name.sh
- Make the script executable:
-
Input Directory Path:
- You will be prompted to input the directory path where the files are located.
-
Organizing Files:
- The script identifies each file's extension and moves it to a corresponding subdirectory.
-
File Criteria:
- Regular files (not directories) that are not executable are considered for organization.
- The script distinguishes empty files and determines their type using the
filecommand or extracts the extension directly.
-
Directory Creation:
- Subdirectories are created dynamically based on file extensions if they do not already exist.
-
Cleanup Message:
- Once all files are processed, a message is displayed indicating that the directory has been successfully cleaned.
- Bash environment (Linux, macOS, Git Bash on Windows, etc.)
- The
filecommand for accurate file type determination.
- The script assumes that the
filecommand is available in your environment for accurate file type identification. - It is recommended to review and customize the script based on specific use cases or requirements.