AppleScript to make the preview image become the master in Aperture library

apertureapplescript

Recently I accidently deleted the folder that contained most of my Aperture library (I didn't think they were refenced, I assumed they were all in my library file, but unfortunately this was not true) and this is causing me a major problem.

My first step was to run Stellar Phoenix Disk Recovery, which was doing well until it broke my second external drive that they were being copied onto. I then scanned it again and put them onto a exFAT volume. However there are now issues with this volume, and the folders are not showing up in finder or Aperture. I can see the files in terminal and at present am trying to copy them over via rsync.

Therefore I need advice regarding the following:

Being able to see the files and folders containing my found images on my exFAT volume. If this works it will be very much benefical and may save the need to do the latter.

As a last resort, I may need to merge the previews into the masters, as otherwise I will no longer have any copy of the images files. How would I do this by means of applescript please?

I've pretty much lost all of my images from my life, so would really appreciate some help here.

More info: https://discussions.apple.com/message/23529900?ac_cid=op123456#23529900

Ideally, the script needs to:

  • Loop through images tagged with the custom keyword 'missing'.
  • Get the source of the preview image
  • Duplicate the preview image
  • Change the master location to that of the new duplicated image
  • Continue loop through next images

First go at code:

    on run
 tell application "Aperture"
activate
set imageSel to (get selection)
if imageSel is {} then
  error "Please select an image."
else
  repeat with i from 1 to count of imageSel


       <!-- do duplication in this repeat loop -->


  end repeat
end if
end tell

Best Answer

In the case that your library has SOME structure left to it, press and hold the command and option keys, then open Aperture. A window will appear that says, "Photo Library First Aid". Tick the "Rebuild Database" option. I would recommend duplicating the library in case something goes terribly wrong.