Forum

Author Topic: Change images names after Align photos  (Read 10120 times)

Matt

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Change images names after Align photos
« Reply #15 on: April 28, 2020, 05:22:34 PM »
Hi Alexey,

Can you please update the rename photo script below for use in version 1.6.

Many Thanks

Matt

import PhotoScan

chunk = PhotoScan.app.document.chunk

string = PhotoScan.app.getString("Input prefix to be added to the selected camera labels:")
for camera in chunk.cameras:
   if camera.selected:
      camera.label = "_".join([string,camera.label])
      
print("Script finished")

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14840
    • View Profile
Re: Change images names after Align photos
« Reply #16 on: April 28, 2020, 07:08:03 PM »
Hello Matt,

I think, it should be the following:

Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk

string = Metashape.app.getString("Input prefix to be added to the selected camera labels:")
for camera in chunk.cameras:
   if camera.selected:
      camera.label = "_".join([string,camera.label])     
print("Script finished")
Best regards,
Alexey Pasumansky,
Agisoft LLC

bassistas

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Change images names after Align photos
« Reply #17 on: February 12, 2022, 05:17:22 AM »
THis one should also update the image paths:
Code: [Select]
import PhotoScan

chunk = PhotoScan.app.document.chunk

string = PhotoScan.app.getString("Input prefix to be added to the selected camera labels:")
index = PhotoScan.app.getInt("Input starting index:")

for camera in chunk.cameras:
if camera.selected:
if camera.label[-4] == ".":
camera.label = "_".join([string,"{:04d}".format(index)]) + camera.label[-4:]
else:
camera.label = "_".join([string,"{:04d}".format(index)])
camera.photo.path = camera.photo.path.rsplit("/",1)[0] + "/" + camera.label
index += 1

print("Script finished")

Hello,
I just tried this script and it renamed successfully all my photos but it does remove also the jpeg extension from the file names. Can anyone fix this problem on the script? thanks