How can I create a Bash script to unrar files with a right-click?

0
14
Asked By CreativeCoder47 On

I'm facing an issue with Linux Mint's archive manager crashing whenever I try to use the right-click 'extract here' option for multi-part rar archives. Currently, I have to open the terminal and manually run 'unrar x *part1.rar' to extract the files. I'd like to simplify this process by writing a Bash script that I can place in "/Applications" and add to the 'Open With' menu, allowing me to extract rar files more easily with just a right-click. However, I'm struggling to get the script to work correctly. Here's what I've written so far:

```bash
#! /bin/bash
if "*part1.rar" do unrar x
Pause -p "Check for errors then press any key to continue"
exit
```

2 Answers

Answered By NinjaScriptGuru On

You might want to rethink your script design; using 'if' may not actually be necessary. If you're trying to check if the file exists, you could simply run 'unrar x' directly on the file path without the need for an 'if'. Just make sure it checks for multi-part files first!

Answered By ShellScriber99 On

It looks like your 'if' statement is a bit off. You need to specify a condition that can respond with 'yes' or 'no'. For example:

```bash
if [ -f "*part1.rar" ]; then
unrar x "*part1.rar"
fi
```
Also, remember that 'Pause' is not a valid bash command. Instead, you can use 'read -p' to prompt for input. Here's a simplified version of your script that should work better!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.