Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Source = (r"D:Backuptest2") #where the files originate
  2. Destination = (r"D:BackupZipFilesToMove") #where they move to
  3. SendZipfiles = (['C:BackupFilesRichCopyControls.cmd']) #the .cmd file
  4. from os import listdir
  5. from os.path import isfile, join
  6. onlyfiles = [ f for f in listdir(Source) if isfile(join(Source,f)) ] v#get each file in folder
  7. Amount = len(onlyfiles) #how many files are in folder
  8. Counter = 0
  9. lst = onlyfiles #give the list the name lst
  10. while(Counter < Amount):
  11. zf = zipfile.ZipFile(lst[Counter],"w", zipfile.ZIP_DEFLATED,allowZip64=True) # create zip
  12. zf.write(os.path.join(lst[Counter])) #zip it up
  13. zf.close() #close the zip
  14. shutil.move(os.path.join(lst[Counter]),Destination) #move to zip folder
  15. 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