3

I m currently using the shutil library to zip the file,

Current folder structure

In the d drive

A_zipdirectory.py for running the python code

A_dest folder to be zipped

A_backup folder that will stored the zipped folder

Python code

import shutil

import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

zip_loc = 'D:/A_dest'
zip_dest = 'D:/A_backup'
shutil.make_archive(base_dir=zip_loc, root_dir=zip_loc, format='zip', 
base_name=zip_dest)

When i run this, No error occurs, but i cannot zip and move the file to the backup folder, Any idea? Many thanks

enter image description here

3
  • Are you sure your folder path is correct? If you use an absolute path, maybe your file(or dir) path should prefix with driver letter.(e.g. D:/A_dest) Commented Sep 29, 2018 at 14:29
  • Have tried to use D:/A_dest with no luck, just starting to learn this Commented Sep 29, 2018 at 14:31
  • As my comment says you should change your path on Windows. stackoverflow.com/questions/2953834/windows-path-in-python Commented Sep 29, 2018 at 14:34

1 Answer 1

1

try to add logger and see what happening. (you can deliver logger to shutil.make_archive)

sorry it answer and not comment, i can't comment yet

Sign up to request clarification or add additional context in comments.

6 Comments

FileNotFoundError: [WinError 2] The system cannot find the file specified: 'A_dest'
where do you run the script from?
try to use absolute path instead of relative
? care to explain further
in your case: r"d:\A_backup". relative path is partial, and absolute is full path. it like telling the python look for the file here, or look for the file in (36.395121, 17.346487)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.