Home
Name Modified Size InfoDownloads / Week
README.md 2025-03-18 4.9 kB
tray.ps1 2025-03-18 1.9 kB
tray.sh 2025-03-18 1.7 kB
Totals: 3 Items   8.5 kB 0

TrayTrash - Advanced Trash Management System

Overview

TrayTrash is a command-line utility designed to manage deleted files in a manner similar to the "Trash" or "Recycle Bin" functionality found in modern operating systems. It provides a safe way to delete files by moving them to a designated trash directory, allowing for easy restoration if needed. The tool also includes features for managing the trash directory, such as automatic cleanup of old files, listing contents, and emptying the trash.

This tool is available in two versions: a Bash script for Unix-like operating systems and a PowerShell script for Windows. Both versions offer the same core functionality, ensuring a consistent experience across platforms.

Features

  • Safe Deletion: Files are moved to a trash directory instead of being permanently deleted.
  • Automatic Cleanup: When the trash directory reaches a specified limit, the oldest files are automatically removed.
  • Restoration: Files can be restored from the trash to their original location.
  • Trash Management: Users can list the contents of the trash, empty it entirely, or restore specific files.
  • Logging: All actions are logged for auditing and troubleshooting purposes.

Installation

Unix-like Operating Systems (Linux, macOS, etc.)

  1. Download the Script:
  2. Download the tray.sh script from the following link: Download tray.sh

  3. Make the Script Executable:

  4. Open a terminal and navigate to the directory where tray.sh is located.
  5. Run the following command to make the script executable: bash chmod +x tray.sh

  6. Run the Script:

  7. Execute the script using the following command: bash ./tray.sh [command] [filename]

Windows

  1. Download the Script:
  2. Download the tray.ps1 script from the following link: Download tray.ps1

  3. Run the Script:

  4. Open PowerShell and navigate to the directory where tray.ps1 is located.
  5. Execute the script using the following command: powershell . ray.ps1 [command] [filename]

Usage

Commands

  • Delete a File:
  • Move a file to the trash directory.
  • Syntax: bash ./tray.sh delete <filename> powershell . ray.ps1 delete <filename>

  • Restore a File:

  • Restore a file from the trash directory to its original location.
  • Syntax: bash ./tray.sh restore <filename> powershell . ray.ps1 restore <filename>

  • Empty the Trash:

  • Permanently delete all files in the trash directory.
  • Syntax: bash ./tray.sh empty powershell . ray.ps1 empty

  • List Trash Contents:

  • Display the contents of the trash directory.
  • Syntax: bash ./tray.sh list powershell . ray.ps1 list

Examples

  1. Delete a File: bash ./tray.sh delete example.txt powershell . ray.ps1 delete example.txt

  2. Restore a File: bash ./tray.sh restore example.txt powershell . ray.ps1 restore example.txt

  3. Empty the Trash: bash ./tray.sh empty powershell . ray.ps1 empty

  4. List Trash Contents: bash ./tray.sh list powershell . ray.ps1 list

Configuration

Trash Directory

  • The trash directory is located at ~/Trash on Unix-like systems and $env:USERPROFILE\Trash on Windows.
  • You can modify the TRASH_DIR variable in the script to change the location of the trash directory.

Trash Limit

  • The maximum number of files allowed in the trash directory is set by the TRASH_LIMIT variable.
  • The default limit is 10 files. You can adjust this value in the script to suit your needs.

Logging

  • All actions performed by the script are logged to a file named trash_log.txt in the trash directory.
  • The log file includes the date, time, and description of each action.

Troubleshooting

  • File Not Found: Ensure the file you are trying to delete or restore exists and is accessible.
  • Permission Issues: Make sure you have the necessary permissions to delete or move files.
  • Log File: Check the trash_log.txt file in the trash directory for detailed information about actions performed by the script.

License

TrayTrash is released under the MIT License. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

Support

For support or to report issues, please visit the TrayTrash project page on SourceForge.

Source: README.md, updated 2025-03-18