How I can delete an image (move it into the trash) from applescript by giving the filename and path of the image locate on the drive.
This script will be started from the shell and may get the (valid) filename including the path (size or other properties if needed) as parameter.
So far I could manage to select the image by name (which is the filename usually) and set a comment on it. So I can search for that comment and delete all images with that comment at once. But with random image names this is not possible because you find unrelated pictures for the name.
iPhoto stores a POSIX path as opposed to the Finder path (i.e., ":"-delimited). So, if you have the name and the path, then you can use the
image pathproperty of thephotoclass for comparison and delete the photo when there is a match. iPhoto has a list property forphotosto make this easy. You'll have to clean the path you get from the shell before you do the comparison with the image path stored in iPhoto (remove the "\" escape characters, mainly).Of course, when I tried this,
deletegave me an error -10000, which means the handler failed. (Not much I can do about that one.)