Automatically unzip a file using "inoticoming" in Ubuntu

Submitted by sysop on Sun, 05/21/2023 - 22:42

To automatically unzip a file as soon as it is downloaded on Ubuntu, you can use the inoticoming tool, which allows you to monitor a specific folder for incoming files and perform actions on them. Here's a step-by-step guide to setting it up:

  1. Install inoticoming: Open a terminal on your Ubuntu machine. Run the following command to install inoticoming:
    sudo apt-get install inoticoming
  2. Create a Folder for Incoming Files: Decide on a folder where the downloaded files will be placed. For example, let's use ~/Downloads/incoming as the incoming folder. Create the folder by running the following command:

    mkdir -p ~/Downloads/incoming
  3. Write an Unzip Script: Create a script that will handle the unzipping of the downloaded files. For this example, let's assume you want to unzip ZIP files.
    Open a text editor and create a new file. For instance, you can use the following command:

    nano ~/unzip_script.sh
  4. In the text editor, add the following content to the script:
    #!/bin/bash
    cd ~/Downloads/incoming
    unzip "$1"

    Save and exit the text editor (Ctrl + X, followed by Y and Enter).

  5. Set up inoticoming: Open a terminal and run the following command to start monitoring the incoming folder and execute the script whenever a new file is detected:

    inoticoming ~/Downloads/incoming ~/unzip_script.sh {}

    That's it! Now, whenever a new ZIP file is downloaded and placed in the ~/Downloads/incoming folder, the unzip_script.sh script will be triggered, and the file will be automatically extracted. You can modify the script to handle other archive formats or perform additional actions as needed.

Amazon banner

Bulk discounts