Created
March 15, 2018 08:35
-
-
Save ndvo2710/254326c7ab2853b11028e4531365436b to your computer and use it in GitHub Desktop.
py: File, Folder, Directory snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOME = os.getcwd() | |
OUTPUT_DIR = os.path.join(HOME, 'Output') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src = os.path.join(......) | |
dst = os.path.join(......) | |
shutil.move(src, dst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for elem in os.listdir(DOWNLOAD_DIR): | |
if elem.endswith('.zip'): | |
src = os.path.join(DOWNLOAD_DIR, elem) | |
dst = os.path.join(........) | |
shutil.move(src, dst) | |
time.sleep(20) | |
zipPath = os.path.join(dst, elem) | |
zip_ref = zipfile.ZipFile(zipPath, 'r') | |
zip_ref.extractall(dst) | |
zip_ref.close() | |
os.remove(zipPath) | |
print "Zip file has been extracted." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment