Python Forum
Python script that recursively zips folders WITHOUT nesting the folder inside the zip
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python script that recursively zips folders WITHOUT nesting the folder inside the zip
#2
(Feb-11-2020, 04:27 PM)umkc1 Wrote: for filename in files:
        zf.write(os.path.join('620_PANO_1_20190802', filename)

The documentation says to add the argument "arcname" to the .write() line. Otherwise your filename is used by default and the directory is included.

maybe try this where arcname is the name you want to give the archive:
 for filename in files:
        zf.write(os.path.join('620_PANO_1_20190802', filename, arcname)
Reply


Messages In This Thread
RE: Python script that recursively zips folders WITHOUT nesting the folder inside the zip - by michael1789 - Feb-11-2020, 09:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to add Python folder in Windows Registry ? Touktouk 1 281 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 361 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 569 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  What script to paste folders thenewcoder 1 678 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,297 Jun-29-2023, 11:57 AM
Last Post: gologica
  python move folders and subfolders not working mg24 5 2,199 Nov-09-2022, 02:24 PM
Last Post: Larz60+
  python gzip all files from a folder mg24 3 4,040 Oct-28-2022, 03:59 PM
Last Post: mg24
  Make a python folder .exe Extra 0 1,035 Jun-10-2022, 01:20 AM
Last Post: Extra
  How to return the next page from json recursively? sandson 0 1,162 Apr-01-2022, 11:01 PM
Last Post: sandson
  Help Needed | Read Outlook email Recursively & download attachment Vinci141 1 4,101 Jan-07-2022, 07:38 PM
Last Post: cubangt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020