[Python] Run Python script to Extract file in different folder

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I have trouble with my Python script. Currently, my script works to run the script which is file and myscript.py in the same folder. I want to run myscript.py to extract files in another folder.

    topology [​IMG]

    myscript.py

    import os
    import re

    # Setup main paths.
    myfiles = os.listdir()

    pattern = re.compile(r"filesextract\d+")

    for files in myfiles:
    if(pattern.match(files) != None):
    command = "tar -xzvf " + files
    os.system(command)

    Continue reading...

Compartilhe esta Página