Last active
June 9, 2025 17:31
-
-
Save scivision/39f387f8b530d4cf473efa9eccf5bbd6 to your computer and use it in GitHub Desktop.
Create tar archive of WSPR / WSJT-X raw audio save files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import tarfile | |
import platform | |
from pathlib import Path | |
import argparse | |
from datetime import datetime | |
a = argparse.ArgumentParser( | |
description="Compress and upload raw WSPR data to science archive." | |
) | |
a.add_argument("mycall", type=str, help="Your callsign") | |
a.add_argument("-date", type=str, help="Approximate date recording began (YYYY-MM-DD)", default=datetime.now().strftime("%Y-%m-%d")) | |
a.add_argument("-outdir", type=str, help="Output directory for the tar file", default=".") | |
args = a.parse_args() | |
# Create output directory if it does not exist | |
outdir = Path(args.outdir).expanduser().resolve(strict=False) | |
outdir.mkdir(parents=True, exist_ok=True) | |
# Determine WSJT-X save directory based on OS | |
system = platform.system() | |
match system: | |
case "Linux": | |
datadir = Path.home() / ".local/share/WSJT-X/save" | |
case "Darwin": | |
datadir = Path.home() / "Library/Application Support/WSJT-X/save" | |
case "Windows": | |
datadir = Path(os.environ["LOCALAPPDATA"]) / "WSJT-X/save" | |
case _: | |
raise SystemExit(f"Unsupported OS: {system}") | |
# Create compressed tar archive of .wav files | |
wav_files = datadir.glob("*.wav") | |
archive = outdir / f"{args.mycall}-{args.date}.tar" | |
with tarfile.open(archive, "w") as tar: | |
for i, wav_file in enumerate(wav_files, start=1): | |
print(f"{wav_file.name} => {archive}") | |
tar.add(wav_file, arcname=wav_file.name) | |
if i == 0: | |
raise SystemExit(f"No .wav files found in the save directory {datadir}.") | |
print(f"Created with {i} .wav files") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment