Forum

Author Topic: Rename source images by date and time when images were taken  (Read 2134 times)

jkova96

  • Full Member
  • ***
  • Posts: 184
    • View Profile
Rename source images by date and time when images were taken
« on: December 22, 2024, 12:06:41 PM »
Hi to everyone,
Does someone know to write a script which would replace original image name of each photo in chunk with their date and time of capture?
Here's the thing, I have multiple photos with same name, but also I want to order images on the way how I took them in the field. Unfortunatelly project is very large and time consuming will be if I decide to process everything again. I think that the best option to solve this is to rename source images with captured date and time in reference tab. Of course pictures have date and time when referring to photos tab. (Check picture in attachments)

For example for image DJI_0001 rename name would be 20230513_133840 (Check for image in attachments)

Have a nice day!

J.K.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15413
    • View Profile
Re: Rename source images by date and time when images were taken
« Reply #1 on: December 23, 2024, 07:21:00 PM »
Hello Josip,

If you need just to rename the camera labels in the project, then you can use the following code:

Code: [Select]
chunk = Metashape.app.document.chunk
for camera in chunk.cameras:
   if camera.type == Metashape.Camera.Type.Regular:
      if "Exif/DateTimeOriginal" in camera.photo.meta.keys():
          camera.label = camera.photo.meta["Exif/DateTimeOriginal"].replace(":","").replace(" ", "_")

As for the renaming of the original files, I would suggest to do that using special utilities or file manager extensions. And do that before adding images to Metashape project, otherwise you will need to replace somehow the paths in the project.
Best regards,
Alexey Pasumansky,
Agisoft LLC