Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

looping over folder to extract zip winrar python

good = {"rar", "zip", "r00"}
for root, dirs, files in os.walk(path):
    if not any(f.endswith(".mkv") for f in files):
        tmp = {"rar": [], "zip": []}
        for file in files:
            ext = file[-4:]
            if ext == ".mkv":
                break
            elif ext in good:
                tmp[ext].append(join(root, file))
        else:
            for p in tmp.get(".zip", []):
                print("Unzipping ", p, "...")
                check_call(["unzip", p, "-d", root])
            for p in tmp.get(".rar", []):
                check_call(["unrar", "e", p, root])
Comment

looping over folder to extract zip winrar python

for root, dirs, files in os.walk(path):
    if not any(f.endswith(".mkv") for f in files):
        for file in files:
            pth = join(root, file)
            if file.endswith("zip"):
                print("Unzipping ",file, "...")
                check_call(["unzip" , pth, "-d", root])
            elif file.endswith((".rar",".r00")):
                check_call(["unrar","e", pth,  root])
Comment

PREVIOUS NEXT
Code Example
Python :: django multi column index 
Python :: dalsports 
Python :: is : and :: the same in python slice 
Python :: western school district 
Python :: pyqt stretch image 
Python :: How did you determine the chromosome numbers and how does that relate to heredity? 
Python :: odoo site map for employees hierarchy 
Python :: mylist = [“hello”, “bye”,”see ya”,”later”] phrase = mylist[1] 
Python :: python selenium firefox handle ssl bypass 
Python :: rotate an image python keras 
Python :: python-wordpress-xmlrpc custom fields 
Python :: How to send data to scrapy pipeline to mongodb 
Python :: load pandas dataframe with one row per line and 1 column no delimiter 
Python :: dictionnaire 
Python :: odd number list generator 
Python :: Implement a function word_list() that reads the 5_letter_words.txt file and returns a list of the words in the file. 
Python :: python for schleife 
Python :: flask logging miguel grinberg 
Python :: raspberry pi pwm controlled leds 
Python :: encrypt 
Python :: disable kivy button in kv 
Python :: what is cls and args in python classmethod 
Python :: ing or ly add to str 
Python :: python datediff days 
Python :: django chain query 
Python :: looping through the dict. and return the key with the highest value 
Python :: how to check if the update_one success in flask 
Python :: dropping original values after merging scaled values 
Python :: Horizontal concatication 
Python :: python sliding window maximum 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =