from path import path
import os
import re

thisDir = path(os.getcwd())
archives = re.compile("part01\.rar$")

for f in thisDir.files():
    if( archives.search(f.name) ):
        if os.fork() == 0:
            os.execlp("unrar","unrar", "x", "-ad", f.abspath())

@@ -10,17 +10,17 @@
  import 
-p
+P
 ath%0Aimpo
@@ -39,20 +39,289 @@
  re%0A
-%0AthisDir = p
+import argparse%0Aimport subprocess%0A%0Aparser = argparse.ArgumentParser()%0Aparser.add_argument('-d', '--dir', default='.', help='path to look for rar archives')%0Aparser.add_argument('-t', '--to', default='.', help='path to extract content to')%0A%0Aargs = parser.parse_args()%0Aarchive_dir = P
 ath(
@@ -340,17 +340,19 @@
 %0Aarchive
-s
+_re
  = re.co
@@ -358,16 +358,17 @@
 ompile(%22
+(
 part01%5C.
@@ -370,16 +370,23 @@
 t01%5C.rar
+)%7C(r00)
 $%22)%0A%0Afor
@@ -395,13 +395,17 @@
  in 
-thisD
+archive_d
 ir.f
@@ -419,25 +419,26 @@
 %0A    if(
- 
 archive
-s
+_re
 .search(
@@ -444,17 +444,16 @@
 (f.name)
- 
 ):%0A     
@@ -459,87 +459,191 @@
     
-if os.fork() == 0:%0A            os.execlp(%22unrar%22,%22unrar%22, %22x%22, %22-ad%22, f.abspath()
+try:%0A            cp = subprocess.run(%5B%22unrar%22, %22x%22, %22-ad%22, f.abspath(), Path(args.to)%5D, stderr=subprocess.PIPE)%0A        except subprocess.CalledProcessError:%0A            print(cp.stderr
 )%0A

Make extract-all more robust