Skip to content

Instantly share code, notes, and snippets.

@ndvo2710
Created March 15, 2018 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndvo2710/254326c7ab2853b11028e4531365436b to your computer and use it in GitHub Desktop.
Save ndvo2710/254326c7ab2853b11028e4531365436b to your computer and use it in GitHub Desktop.
py: File, Folder, Directory snippets
HOME = os.getcwd()
OUTPUT_DIR = os.path.join(HOME, 'Output')
src = os.path.join(......)
dst = os.path.join(......)
shutil.move(src, dst)
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