> [!tldr] Some sample [[Python]] for making a folder of pictures produce a CSV of locations A thing I wrote with [[Large Language Models|LLMs]]. Super easy (after installing `exiftool`). ```python import subprocess import json import csv INPUT_DIR = "photos/" OUTPUT_CSV = "geolocations.csv" def main(): cmd = [ "exiftool", "-json", "-r", "-GPSLatitude", "-GPSLongitude", "-GPSAltitude", "-CreateDate", "-ModifyDate", INPUT_DIR ] result = subprocess.run( cmd, capture_output=True, text=True ) if result.returncode != 0: print("ExifTool error:", result.stderr) return data = json.loads(result.stdout) rows = [] for item in data: if "GPSLatitude" in item and "GPSLongitude" in item: rows.append({ "file_path": item.get("SourceFile"), "latitude": item.get("GPSLatitude"), "longitude": item.get("GPSLongitude"), "altitude": item.get("GPSAltitude"), "create_date": item.get("CreateDate"), "modify_date": item.get("ModifyDate"), }) if not rows: print("No geolocation data found.") return with open(OUTPUT_CSV, "w", newline="", encoding="utf-8") as f: writer = csv.DictWriter( f, fieldnames=[ "file_path", "latitude", "longitude", "altitude", "create_date", "modify_date", ] ) writer.writeheader() writer.writerows(rows) print(f"Wrote {len(rows)} rows to {OUTPUT_CSV}") if __name__ == "__main__": main() ``` **** # More ## Source - self