• No products in the cart.

DevOps on AWS – Python Scripts 8 : File Operations


import os
import shutil
from zipfile import ZipFile
from os import path
from shutil import make_archive
fileName = “test.txt”
newFileName = “test.txt.bak”
def main():

# get the path to the file in the current directory
src = path.realpath(fileName);
# Process 1 : now put things into a ZIP archive
root_dir,tail = path.split(src)
print root_dir , ”   ” , tail
shutil.make_archive(“fileSize_archive”, “zip”, root_dir)

# Process 2 : more fine-grained control over ZIP files
with ZipFile(“testFileSize.zip”,”w”) as newzip:
for (dirname, dirs, files) in os.walk(“.”):
for filename in files:
if filename.endswith(“.py”):
  # print fileName, ” is not available”
if __name__== “__main__”:
February 22, 2021

Contact Address

Rise ‘n’ Shine Technologies:
Third Floor, Plot No1(Part), near KPHB Metro Station, KPHB Bagyanagar Colony, Kukatpally Main road, Balanagar Mandal, Rangareddy Dist-500072

Landmarks : Above VIOLET & PURPLE, near PJR statue, kphb metro station

  8686 98 8042


All rights reserved.
error: Alert: Content is protected !!