Im not understanding script. Please someone..
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
Im not understanding script. Please someone..
I have read a lot of shell script tutors off of google,
and linux mint forums. They say there easy, but am
having a lot of trouble understanding them. I have ADHD.
My reading, writing, and consintration is very bad. I
was wondering, if someone can rewrite this run.bat file
into a linux shell script file for me. I will be double
clicking on the file to run it from a file manager.
The files name is run.bat...
Inside the file is only one line...
unrar e file_1.rar
Can someone turn that one line into a shell script file
please?
Also, i have a multi part rar file...
file_2.part1.rar
file_2.part2.rar
file_2.part3.rar
file_2.part4.rar
Will that same command (unrar e file.rar) unrar
multipart file?
Also, that file_1.rar was made in windows. It has a
windows folder in it called temp. Inside that temp
folder is all the files. Will that command (unrar e
file_1.rar) keep the original structure?
I mite have to have two different run.bat files...
run_1.bat
run_2.bat
And by the way..both files are password protected.
Can someone write these scripts for me? With me having
ADHD, i am having a hard time understanding the easy
tutors on google and mint forms. They are making no
since to me.
I do no a lot on how to use file managers. I do no a lot
about windows folders, how to create them, how to move
around them, how to copy, cut, paste, rename and a lot
of other file managment stuff.
I just need to work with rar files in linux from a file
manager. And the easyest way for me to do that is by
unraring a rar file by double clicking on an shell
script file. The same way you would with an run.bat
file.
So will someone write a couple simple shell script files
to unrar these files for me? Please?
Thanks a Lot
and linux mint forums. They say there easy, but am
having a lot of trouble understanding them. I have ADHD.
My reading, writing, and consintration is very bad. I
was wondering, if someone can rewrite this run.bat file
into a linux shell script file for me. I will be double
clicking on the file to run it from a file manager.
The files name is run.bat...
Inside the file is only one line...
unrar e file_1.rar
Can someone turn that one line into a shell script file
please?
Also, i have a multi part rar file...
file_2.part1.rar
file_2.part2.rar
file_2.part3.rar
file_2.part4.rar
Will that same command (unrar e file.rar) unrar
multipart file?
Also, that file_1.rar was made in windows. It has a
windows folder in it called temp. Inside that temp
folder is all the files. Will that command (unrar e
file_1.rar) keep the original structure?
I mite have to have two different run.bat files...
run_1.bat
run_2.bat
And by the way..both files are password protected.
Can someone write these scripts for me? With me having
ADHD, i am having a hard time understanding the easy
tutors on google and mint forms. They are making no
since to me.
I do no a lot on how to use file managers. I do no a lot
about windows folders, how to create them, how to move
around them, how to copy, cut, paste, rename and a lot
of other file managment stuff.
I just need to work with rar files in linux from a file
manager. And the easyest way for me to do that is by
unraring a rar file by double clicking on an shell
script file. The same way you would with an run.bat
file.
So will someone write a couple simple shell script files
to unrar these files for me? Please?
Thanks a Lot
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Im not understanding script. Please someone..
The Mint community is largely a community of people new to Linxu so, while there are a few here experienced in writing shell scripts, those who have done such things are few in number.
Your script would have to ask where your RAR files are, and where you want the output put.
You mention that you are comfortable in work with directories inside a file manager. Good, you should be able to move files around and know where they are. Once you can do that you have the ability to open a terminal in the directory where your RAR files are and execute unrar filename.rar .
Why would that not work for you?
Regards,
Your script would have to ask where your RAR files are, and where you want the output put.
You mention that you are comfortable in work with directories inside a file manager. Good, you should be able to move files around and know where they are. Once you can do that you have the ability to open a terminal in the directory where your RAR files are and execute unrar filename.rar .
Why would that not work for you?
Regards,
Last edited by xenopeek on Tue May 27, 2014 11:38 am, edited 1 time in total.
Reason: pointless quote of entire post above removed
Reason: pointless quote of entire post above removed
Re: Im not understanding script. Please someone..
Well, that's easy
That's the entire script. The first line is mandatory; marks this as a Bash script. You have to then right-click the file, go to Properties, and in Permissions set to allow executing the file as a program.
But probably if you double-click your rar file from your file manager, it will already open it?
Code: Select all
#!/bin/bash
unrar e file_1.rar
But probably if you double-click your rar file from your file manager, it will already open it?
- tdockery97
- Level 14
- Posts: 5058
- Joined: Sun Jan 10, 2010 8:54 am
- Location: Mt. Angel, Oregon
Re: Im not understanding script. Please someone..
Or you can do it the lazy way like me. Right-click the RAR file and select "Extract Here".
Mint Cinnamon 20.1
Re: Im not understanding script. Please someone..
Thanks for telling me that the first line is awaysxenopeek wrote:Well, that's easyThat's the entire script. The first line is mandatory; marks this as a Bash script. You have to then right-click the file, go to Properties, and in Permissions set to allow executing the file as a program.Code: Select all
#!/bin/bash unrar e file_1.rar
But probably if you double-click your rar file from your file manager, it will already open it?
important in a shell script. i still am having a hard
time getting it to click in my head because of ADHD, but
i've got the shell script figured out now. i've created
two different shell scripts that i will show everyone
how to create. i will post below. Thanks.
Re: Im not understanding script. Please someone..
Some rar files you download off of the internet are madetdockery97 wrote:Or you can do it the lazy way like me. Right-click the RAR file and select "Extract Here".
on windows. I was downloading TV episodes. One out of
five rar files would not extract using archive manager
in linux. I would get (i forgot what the error was) an
error. Thats one out of five rar files that was created
on windows. So for me to get that one out of five rar
file extracted, I would have to type in terminal..
unrar e filename.rar
..to get that one out of five rar file extracted. It was
just taking too much time to do an extraction that way
sence i had so many tv episodes to extract.
Anyway, i did figure out how to create a couple of bash
shell scripts to speed up the process. I thank xenopeek
for showing me a simple script and the rest i figured
out my self.
Next post down i will show how i created two simple bash
shell scripts.
[SOLVED] Im now understanding unrar script. Thanks.
Thanks again xenopeek for showing me a simple script.
Heres how to create 2 different shell scripts to unrar
rar files.
1. Create 2 document files named..
Unrar_File.sh
and
Unrar_Multi-Part_File.sh
2. Put these 2 files in the same directory that your rar
or multi-part rar file is.
3. Open the Unrar_File.sh file with a txt editor like
the editor called pluma.
4. Type these lines in the file..
#!/bin/bash
unrar x *.rar
..and save the Unrar_File.sh file and exit your txt
editor.
But, if you want your rar file to extract to a certain
directory, the second line should look like this..
unrar x *.rar /home/your user name/name of directory
your user name = the user name you used when you
installed linux.
name of directory = the name of the directory you want
the rar file extracted too. For example, here is what i
typed in for my linux computer..
unrar x *.rar /home/lenmanny/episodes
5. Open the Unrar_Multi-Part_File.sh file with a txt
editor like the editor called pluma.
6. Type these lines in the file..
#!/bin/bash
unrar x *.part1.rar
..and save the Unrar_Multi-Part_File.sh file and exit
your txt editor.
But, if you want your rar file to extract to a certain
directory, the second line should look like this..
unrar x *.part1.rar /home/your user name/name of
directory
your user name = the user name you used when you
installed linux.
name of directory = the name of the directory you want
the rar file extracted too. For example, here is what i
typed in for my linux computer..
unrar x *.part1.rar /home/lenmanny/episodes
7. Now that you have your shell script files created,
and put in the directory where your rar file is, theres
one more thing you have to do...one at a time, right-
click on the files you created, go to properties, in the
Permissions tab, put a check mark in the allow executing
the file as a program.
8. To extract a rar file with one of the two shell
script files you created, just double-click the script
file, choose run terminal, and thats it. The rar file
will extract.
Heres how to create 2 different shell scripts to unrar
rar files.
1. Create 2 document files named..
Unrar_File.sh
and
Unrar_Multi-Part_File.sh
2. Put these 2 files in the same directory that your rar
or multi-part rar file is.
3. Open the Unrar_File.sh file with a txt editor like
the editor called pluma.
4. Type these lines in the file..
#!/bin/bash
unrar x *.rar
..and save the Unrar_File.sh file and exit your txt
editor.
But, if you want your rar file to extract to a certain
directory, the second line should look like this..
unrar x *.rar /home/your user name/name of directory
your user name = the user name you used when you
installed linux.
name of directory = the name of the directory you want
the rar file extracted too. For example, here is what i
typed in for my linux computer..
unrar x *.rar /home/lenmanny/episodes
5. Open the Unrar_Multi-Part_File.sh file with a txt
editor like the editor called pluma.
6. Type these lines in the file..
#!/bin/bash
unrar x *.part1.rar
..and save the Unrar_Multi-Part_File.sh file and exit
your txt editor.
But, if you want your rar file to extract to a certain
directory, the second line should look like this..
unrar x *.part1.rar /home/your user name/name of
directory
your user name = the user name you used when you
installed linux.
name of directory = the name of the directory you want
the rar file extracted too. For example, here is what i
typed in for my linux computer..
unrar x *.part1.rar /home/lenmanny/episodes
7. Now that you have your shell script files created,
and put in the directory where your rar file is, theres
one more thing you have to do...one at a time, right-
click on the files you created, go to properties, in the
Permissions tab, put a check mark in the allow executing
the file as a program.
8. To extract a rar file with one of the two shell
script files you created, just double-click the script
file, choose run terminal, and thats it. The rar file
will extract.
-
- Level 2
- Posts: 88
- Joined: Tue Jun 25, 2013 8:50 pm
Re: Im not understanding script. Please someone..
Code: Select all
#!/bin/bash
[ ! -d $2 ] && mkdir -p $2
find $1 -iname "*.rar" -exec unrar -x {} $2 \;
Code: Select all
if [ ! -d $2 ] ; then
mkdir -p $2
fi
Code: Select all
./unrarscript ~/rarfiles ~/rarextract
Re: Im not understanding script. Please someone..
Hi,tadaensylvermane wrote:the first line is probably more clear like this.Code: Select all
#!/bin/bash [ ! -d $2 ] && mkdir -p $2 find $1 -iname "*.rar" -exec unrar -x {} $2 \;
Where $1 is the name of the directory where the Rar files are located. $2 is the path to where you want them extracted. This will create the folder to extract to if it isn't there. Example usage below...Code: Select all
if [ ! -d $2 ] ; then mkdir -p $2 fi
Code: Select all
./unrarscript ~/rarfiles ~/rarextract
Interesting stuff!
Would you please explain how bash interprets/executes [ ! -d $2 ] and {} $2 \; in your first code:select all?
TIA
-
- Level 2
- Posts: 88
- Joined: Tue Jun 25, 2013 8:50 pm
Re: Im not understanding script. Please someone..
I probably am not correct, just know that they work.AlanWalker wrote:Hi,tadaensylvermane wrote:the first line is probably more clear like this.Code: Select all
#!/bin/bash [ ! -d $2 ] && mkdir -p $2 find $1 -iname "*.rar" -exec unrar -x {} $2 \;
Where $1 is the name of the directory where the Rar files are located. $2 is the path to where you want them extracted. This will create the folder to extract to if it isn't there. Example usage below...Code: Select all
if [ ! -d $2 ] ; then mkdir -p $2 fi
Code: Select all
./unrarscript ~/rarfiles ~/rarextract
Interesting stuff!
Would you please explain how bash interprets/executes [ ! -d $2 ] and {} $2 \; in your first code:select all?
TIA
Code: Select all
[ ! -d $2 ]
This...
Code: Select all
[ -d $1 ] && [ ! -d $2 ] ;
rm -r $1 && mkdir $2
Code: Select all
if [ -d $1 ] ; then
if [ ! -d $2 ] ; then
rm -r $1
mkdir $2
fi
fi
Code: Select all
{} $2 \;
Code: Select all
find $1 -iname "*.rar" -exec unrar -x {} $2 \;
Code: Select all
for i in "$(ls -l ${1})" ; do
unrar -x $i $2
done
Re: Im not understanding script. Please someone..
I am the same way about concise code.tadaensylvermane wrote:AlanWalker wrote:tadaensylvermane wrote: This...is the same as this.Code: Select all
[ -d $1 ] && [ ! -d $2 ] ; rm -r $1 && mkdir $2
<snip>Code: Select all
if [ -d $1 ] ; then if [ ! -d $2 ] ; then rm -r $1 mkdir $2 fi fi
I'm not sure I have that for statement correct but the idea is there. Again a single line is easier... at least for me to manage and maintain. Also I use find because more than once it has been brought to my attention that using ls in a script should be avoided. I never understood the reasons but it kept coming up. I don't use it anymore unless I have no choice.
I am interested in regex because I see it used so much in examples of the use of tar and I'm looking into tar.
I've found that there are at least two sites, here and here, that will help me learn to use regex but, thinking that your reply would possibly be of additional help to me, I'd like to ask 'What drove you to learn regex, and how did you learn?'.
-
- Level 2
- Posts: 88
- Joined: Tue Jun 25, 2013 8:50 pm
Re: Im not understanding script. Please someone..
I've tried just "reading a book" a few times. I have an older edition "Learning the bash Shell" and have read a bunch of http://www.tldp.org/LDP/abs/html/ . I learn by example primarily. So generally I've either asked or googled how to do a given thing, then I take what I find and tear it apart until I have a basic understanding of it. I can't quote the actual terminology ( didn't know what regex meant until you asked and I looked it up ) but I can use it to a reasonable degree and am only getting more and more figured out every day. I get a bunch of advice and suggestions on http://www.overclock.net/ linux section as well. I post there often.
-
- Level 2
- Posts: 88
- Joined: Tue Jun 25, 2013 8:50 pm
Re: Im not understanding script. Please someone..
Code: Select all
[ -d $1 ] && [ ! -d $2 ] ;
rm -r $1 && mkdir $2
Code: Select all
[ -d $1 ] && [ ! -d $2 ] && rm -r $1 && mkdir $2