import os import shutil import zipfile # Ensure the data directory exists os.makedirs('data', exist_ok=True) # List of files to copy and compress files = ['questions.json', 'questions_aux.json'] for file in files: # Source and destination paths src_path = os.path.join('old_data', file) dst_path = os.path.join('data', file + '.zip') # Copy and compress the file with zipfile.ZipFile(dst_path, 'w', zipfile.ZIP_DEFLATED) as zipf: zipf.write(src_path, arcname=file) print(f"Copied and compressed {file} to {dst_path}") print("All files have been copied and compressed successfully.")