This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to make a Schedule to Unrar Files one by one

Tags: None
(comma "," separated)
patanias
Registered Member
Posts
2
Karma
0
Hello Guys,

I am using the unrar e command to unrar big files (50GB+) directly from the NAS.

I have many files so I want a way to add a "to do list" that will unrar all the files in that list one by one and not all together.

Is that possible?
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS
Hi!

You could use the wait command in bash to wait for the process to finish. Just use without arguments or give it the pid of the current running process.
patanias
Registered Member
Posts
2
Karma
0
Hello!

thank you for your answer. No idea how to do that.

For now I just "open a terminal here" and once I am in the folder I want I type: Unrar e blabla.rar

Then i proceed to the next one and as a result they all start up together.

What I want is a way to do this but only go the next rar project once the first one is complete.

Thank you in advance!
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS
The bash normally waits for a process to finish, so you do not have to keep care of.

Try following:

Create a dummy-script which does nothing but echo and sleep for 5 seconds:
Code: Select all
#/bin/bash echo "Performing file-operation to wait for...$1"
sleep 5  # to simulate some action


Create a second script (or run from command line):
Code: Select all
for i in one two three; do ./dummyscriptname.bash $i; done


This loop starts the script three times and prints its value via dummy-script and waits for the first run to "finish".

Next one will show the difference between default behaviour, background-processes and wait.
Default is to wait for a process to finish and continue. With the ampersand you can move the process to background and perform the next step without waiting. At least one way of how wait works, simulating the default behaviour and waiting for a process to finish before next step.

Code: Select all
#!/bin/bash

# default behaviour
for i in one two three
 do
  functionReturns=$(./WaitExample_dummy.bash $i)  #open a subshell performing
  echo "Function returned: $functionReturns with Exit-Code $#"
done

# detaching the running instances to background
# this does NOT wait for finishing
for i in one two three
 do
  ./WaitExample_dummy.bash $i &  # & -> to background
done

# detaching and waiting - simulate default behaviour
for i in one two three
 do
  ./WaitExample_dummy.bash $i &  # & -> to background
  wait;  # wait for background process to finish
done


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]