added
This commit is contained in:
1 parent
f676b0084b
commit
909e1858c3
1 file changed
+37
@@ -0,0 +1,37 @@
|
||||
# this simple script takes a folder of Garmin fit zip downloads and extracts the file from each zip
|
||||
import os
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
OUTPUT_FOLDER = r"C:\Users\edsoe\Desktop\Training"
|
||||
|
||||
|
||||
def extract_fit_files(folder):
|
||||
if not os.path.exists(OUTPUT_FOLDER):
|
||||
os.makedirs(OUTPUT_FOLDER)
|
||||
|
||||
zip_files = [f for f in os.listdir(folder) if f.lower().endswith(".zip")]
|
||||
|
||||
if not zip_files:
|
||||
print("No zip files found in this folder.")
|
||||
return
|
||||
|
||||
for zip_name in zip_files:
|
||||
zip_path = os.path.join(folder, zip_name)
|
||||
print(f"Processing ZIP: {zip_name}")
|
||||
|
||||
try:
|
||||
with zipfile.ZipFile(zip_path, "r") as z:
|
||||
for member in z.namelist():
|
||||
if member.lower().endswith(".fit"):
|
||||
print(f" Extracting: {member}")
|
||||
z.extract(member, OUTPUT_FOLDER)
|
||||
except Exception as e:
|
||||
print(f"Error opening {zip_name}: {e}")
|
||||
|
||||
print(f"\nDone! All .fit files extracted to:\n{OUTPUT_FOLDER}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
folder_to_scan = os.getcwd() # whichever folder you run the script from
|
||||
extract_fit_files(folder_to_scan)
|
||||
Reference in new issue
Block a user