Python Forum
Moving specific files then unzipping/decompressing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving specific files then unzipping/decompressing
#1
So I have a folder with a number of subfolders inside. Inside these folders are a couple of .gz files. I need to recursively copy these files to there own folder and then unzip them.the new folder needs to be in the same location as the original file. I have been on this for days, I would post some code, but it would be meaningless as I have no idea which code that I've used came closest to the correct method. Any help greatly appreciated. Id prefer to get it done using only python and only standard libraries, but I'm not limited to that.
Thankyou in advance for any help given
Reply
#2
This is Pretty straight forward:
see: https://docs.python.org/3/library/zipfile.html

Example:
fzip = zipfile.ZipFile('myzip.zip')
# To extract all:
fzip.extractall() # or fzip.extractall("destination_directory_name_here")
# (be cautious of this command, if you don't trust zip source).
Reply
#3
If what you have are gzip files, as the .gz extension usually indicates, there's a standard library module for those too: https://docs.python.org/3/library/gzip.html.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python print all files which contain specific word in it mg24 5 1,188 Jan-27-2023, 11:20 AM
Last Post: snippsat
  python move specific files from source to destination including duplicates mg24 3 1,050 Jan-21-2023, 04:21 AM
Last Post: deanhystad
  Moving files to Folders giddyhead 13 9,003 Mar-07-2021, 02:50 AM
Last Post: giddyhead
  Searching for specific word in text files. JellyCreeper6 1 1,694 Nov-03-2020, 01:52 PM
Last Post: DeaD_EyE
  Moving Files From Subdirectories To Another Directory Harshil 5 3,907 Oct-06-2020, 10:52 AM
Last Post: ndc85430
  Find specific subdir, open files and find specific lines that are missing from a file tester_V 8 3,486 Aug-25-2020, 01:52 AM
Last Post: tester_V
  Read Multiples Text Files get specific lines based criteria zinho 5 3,051 May-19-2020, 12:30 PM
Last Post: zinho
  How to list out specific excel files ajay_pal7 2 2,759 Mar-10-2020, 05:43 AM
Last Post: Larz60+
  extract specific data from a group of json-files ledgreve 3 3,237 Dec-05-2019, 07:57 PM
Last Post: ndc85430
  Delete specific lines contain specific words mannyi 2 4,068 Nov-04-2019, 04:50 PM
Last Post: mannyi

Forum Jump:

User Panel Messages

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