Anthony Papillion <papill...@gmail.com> writes:

> I'm creating an archive of a directory using shutil.make_archive and
> need to skip a single file if it is present in that directory. Is
> there a way to do this or should I be looking to ZipFile to meet this
> need?

You can create a hierarchy of files the way you want it, and then use
‘shutil.make_archive’ once the tree is the way you want it.

* Use ‘tempfile.mkdtemp’ to create a unique temporary working directory,
  and bind its name to ‘working_dir’.

* Use ‘shutil.copytree’ to copy the entire hierarchy from its permanent
  location to the temporary ‘working_dir’ location.

* Use other ‘shutil’ functions to manipulate the files in ‘working_dir’
  the way you want.

* Use ‘shutil.make_archive’ to create an archive of the files from
  ‘working_dir’.

* Use ‘shutil.rmtree’ to remove the ‘working_dir’.

-- 
 \         “All television is educational television. The question is: |
  `\                           what is it teaching?” —Nicholas Johnson |
_o__)                                                                  |
Ben Finney

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to