Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Source = (r"D:Backuptest2") #where the files originate
- Destination = (r"D:BackupZipFilesToMove") #where they move to
- SendZipfiles = (['C:BackupFilesRichCopyControls.cmd']) #the .cmd file
- from os import listdir
- from os.path import isfile, join
- onlyfiles = [ f for f in listdir(Source) if isfile(join(Source,f)) ] v#get each file in folder
- Amount = len(onlyfiles) #how many files are in folder
- Counter = 0
- lst = onlyfiles #give the list the name lst
- while(Counter < Amount):
- zf = zipfile.ZipFile(lst[Counter],"w", zipfile.ZIP_DEFLATED,allowZip64=True) # create zip
- zf.write(os.path.join(lst[Counter])) #zip it up
- zf.close() #close the zip
- shutil.move(os.path.join(lst[Counter]),Destination) #move to zip folder
- p = subprocess.Popen(SendZipfiles) #the problem is here I think, this is where it runs the .cmd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement