environmentaltools.drone.rename

environmentaltools.drone.rename(path: str, polygon_no: str, missions_csv: Path)[source]

Rename mission files and folders based on names from a CSV file.

This function renames mission directories and their contents according to a CSV file that contains new names. It handles both regular files and KMZ archives, updating internal file names within KMZ files and maintaining the directory structure.

Parameters:
  • path (str) – Base path where the missions are located.

  • polygon_no (str) – Polygon number as string, must match the one used in mission creation.

  • missions_csv (Path) – Path to CSV file containing new names for missions (one per line).

Returns:

Renames files and directories in place.

Return type:

None

Raises:
  • FileNotFoundError – If the polygon directory doesn’t exist.

  • ValueError – If directory names cannot be parsed as integers.

Notes

The function expects the following directory structure: - path/missions/polygon_no/001/001.kmz - path/missions/polygon_no/002/002.kmz - path/missions/polygon_no/map_preview/001/001.jpg - path/missions/polygon_no/map_preview/002/002.jpg

CSV file should contain one name per line, corresponding to directories 001, 002, etc. The function will rename both the directories and all files containing the old names.

For KMZ files, internal file names are also updated to maintain consistency.