Aperture: Deleting Images After Import

In a recent post in the Apple Aperture discussion group someone asked if Aperture could delete the image files once they have been imported. One thing I should mention is that the images were being imported from a folder not the camera.

The stock answer is no Aperture doesn't delete images. Even when you delete images inside of Aperture those images are placed in the Aperture trash which you have to empty manually and the they are placed into the system trash which again you have to manually empty.

So you can see Aperture makes it very hard to delete things. But the poster was looking for a way to do this so I came up with the following script. The script can be made the Aperture Applescript action on import. It will run after the images are imported into Aperture. Or it could be made an Aperture Service. Then you would run from the Services menu.

It asks for the folder where the images are and for the file extension of the images. These two questions can be removed and the folder and extension can be hardcoded into the script but I don't think that is a good idea for safety reasons. You really don't want a script automatically removing image files even if they have been imported into Aperture.

-- Set folder to delete
try
	set f to choose folder with prompt "Pick a folder:"
on error number n
	if n is not -128 then
		display dialog "Applescript error: " & n
	end if
	quit
end try
 
 
-- Set the file extension
try
	set ext to text returned of (display dialog "What is the file extension?" default answer "xxx" buttons {"OK", "Cancel"})
on error number n
        if n is not -128 then
		display dialog "Applescript error " & n
	end if
	quit
end try
 
tell application "Finder"
	try
		delete (every item of folder f whose name extension is ext)
	end try
	
end tell
 
-- Display a dialog window asking whether to empty trash or not
set theButton to button returned of (display dialog "Would you like to empty the trash?" with icon caution buttons {"Empty Trash", "Cancel"} default button "Cancel" giving up after 10)
 
if theButton is "Empty Trash" then
	tell application "Finder"
		empty trash
	end tell
end if
AttachmentSize
deletefiles.scpt_.zip3.55 KB