I am very new to python and programming. Right now I'm working on this simple backup program:
This code woks fine. If I try to use a directory with spaces in the path on line 4 like:
I get a zip error:
zip warning: name not matched: C:/test/test
zip warning: name not matched: 2/
zip error: Nothing to do!
I know that my syntax is probably not right and that I probably do not have quotes in the right spot (maybe in the zip_command on line 12). I have tried a lot of different possibilities and cannot seem to get the qoutes in the right spot. Any help or pointers would be greatly appreciated!!!
Code:
#C:\python25\programs\ # File name: test import os, time source = ['C:/test/'] target_directory = 'C:/Backup/' today = target_directory + time.strftime('%m.%d.%Y') now = time.strftime('BackUp@_%H.%M.%S') if not os.path.exists(today): os.mkdir(today) print 'Successfully created directory', today target = os.path.join(today, now + '.zip') zip_command = "zip -qrv %s %s" % (target, '' .join(source)) print zip_command if os.system(zip_command) == 0: print 'sucessful backup to', target else: print 'Backup FAILED'
Code:
source = ['C:/test/test 2/']
zip warning: name not matched: C:/test/test
zip warning: name not matched: 2/
zip error: Nothing to do!
I know that my syntax is probably not right and that I probably do not have quotes in the right spot (maybe in the zip_command on line 12). I have tried a lot of different possibilities and cannot seem to get the qoutes in the right spot. Any help or pointers would be greatly appreciated!!!
Comment