Answer the question
In order to leave comments, you need to log in
What if zip is not an internal or external command?
import os
import time
source = ['C:\\python']
target_dir = '"E:\\program files"'
target = target_dir + os.sep + time.strftime('%Y%m%d%H%M%S') + '.zip'
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
print(zip_command)
if os.system(zip_command) == 0:
print('Резервная копия успешно создана в', target)
else:
print('Создание резервной копии НЕ УДАЛОСЬ')
Answer the question
In order to leave comments, you need to log in
Your Windows does not know about zip, install it or write it in the path, or even better, read about the module https://docs.python.org/3/library/zipfile.html and use it, and not an external program via os.system
Your system has no idea what a zip executable is. Or the path to it is not specified in the PATH environment variable.
Hence the way out: install zip, and if installed, then either add the path to it in the PATH environment variable, or specify the full path to the executable zip file in your script.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question