2

let's say, I have a download of a multipart .rar file, one file inside.

Earlier on Windows with winrar, I opened part01.rar, and started extraction. It was extracting until the end of the last part, that already has been downloaded, and then prompted me for the next part. So I could watch the video, for example, and just hit "repeat" in WinRAR as the next parts had been finished.

Is there a way on ubuntu like this? I would even prefer an automatic command line solution... like one process waiting for new .rar files and then sending the "repeat" to the other process...

I hope, it's not too hard to understand :)

David.

6
  • Edited the tags since WinRAR obviously doesn't (directly) run on Ubuntu. Speaking of which, have you tried running it via Wine?
    – Karan
    Apr 15, 2015 at 8:26
  • I want to solve this with onboard-Tools, not wine or proprietary software (except unrar-nonfree)... Apr 15, 2015 at 9:01
  • 1
    Have you tried unrar x filename.part1.rar?
    – Albin
    Oct 25, 2018 at 11:50
  • The command rar x filename.part1.rar will extract all the filename.part*.rar into a filename file.
    – GAD3R
    Oct 25, 2018 at 13:25
  • Try to extract everything up to the missing part by unrar x -kb myfile.rar.01. Where -kb stands for "Keep broken extracted files".
    – harrymc
    Oct 25, 2018 at 17:53

2 Answers 2

2
+50

A cozy script or simply unrar -kb

Unrar itself provides an option (-kb) to keep broken (or incomplete) extracted files.
The thing to notice here is the exit code (3) that, different from 0, states the occurrence of an error 8-).
So you can simply make a script trying to extract the file until it will succeed (exit code 0).

Reading its help with man unrar (it 's never harmful to give a couple of man at day), you may notice at least a couple of other options useful for the script, namely -o+ and -inul to force the overwriting of the file(s) and to suppress the output.

If the script is named go.sh you may make it executable (chmod u+x ./go.sh) and then execute ./go.sh Myfile.part01.rar. Note you can change the values for the sleeping time and the maximum number of allowed iterations.

#!/bin/bash
MaxCounter=5       # Max number of iteration before it exits 
TimeToSleep=10m    # Time to sleep between 2 iteractions
COUNTER=0

until [ $COUNTER -gt $MaxCounter  ] 
 do 
   printf "### Attempt $COUNTER on $MaxCounter\t"
   unrar x "$@" -kb -inul -o+ \
     && { printf "\n\n### Extraction completed\n\n ### DONE ###\n\n"; exit 0; }\  
     || echo "### Extraction Not completed"
   let COUNTER+=1  
   sleep $TimeToSleep
 done
printf "\n\n### $MaxCounter iterations reached \n\n ### ERROR ### \n"

Note: As disadvantage it will overwrite each time the file... but it was what you were doing with winrar too... The good thing is that it is enough high the probability that the file is in some cache buffer and it will not be really overwritten each time...
If you are able to find a version of unrar (or another program, as e.g. 7z...) that continues the extraction it will be more efficient without overwriting.

2
  • It's not sure that one can overwrite the existing file while it's being viewed in the player. Or another problem, the player may need to close and re-open the video to read the addition, and will then restart from the beginning of the video. Or still another, if reopening is strangely not required, the player may become confused with data that suddenly changed.
    – harrymc
    Oct 31, 2018 at 7:54
  • @harrymc Yes usually you can. Vlc, e.g., allows to read the file even meanwhile you are still creating it (so not yet closed by the process that is writing, and of course not owned by vlc). Moreover it updates even the time to the end... Players, in my experience, are not confused: or they are able to see the new file or they remain stuck with the old one cached... BTW how to make a player aware that the file is changed is another question (and even player dependent). :-)
    – Hastur
    Oct 31, 2018 at 14:06
1

The command for unrar to extract everything possible and ignore missing pieces in a multi-part RAR archive is :

 unrar x -kb myfile.rar.01

Where -kb stands for "Keep broken extracted files".

This should extract the video up to the missing part and stop, thus letting you continue to watch the video from the part before.

Unfortunately, it doesn't wait for missing pieces. A solution that uses a script to feed pieces to unrar and wait, unfortunately cannot work as well, since FIFO (first-in-first-out) streams like /dev/stdin are not seekable, and that's apparently what unrar needs to be able to process the archive.

1
  • Have you verified this yourself or used information you found on the internet? If it's the latter it would be nice if you can provide the source... and thanks anyway for you're research! : )
    – Albin
    Oct 26, 2018 at 18:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .