“Looping Over Pasta para extrair Zip Winrar Python” Respostas de código

Looping Over Pasta para extrair 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])
Courageous Cardinal

Looping Over Pasta para extrair 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])
Courageous Cardinal

Respostas semelhantes a “Looping Over Pasta para extrair Zip Winrar Python”

Perguntas semelhantes a “Looping Over Pasta para extrair Zip Winrar Python”

Mais respostas relacionadas para “Looping Over Pasta para extrair Zip Winrar Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código