l i v e c o d e

Moving Files To The Trash
Mac OS X Only (Mac OS X Only)

Deleting a file is easy (use "delete file"), but suppose you want to move a file to the Trash instead, so the user has the choice of deleting the file or recovering it later? To do this, you can use an AppleScript, or more simply, use the "rename" command:
on TrashIt pFilePath
  get matchText(pFilePath,".*\/(.*?)$",tFile)
  rename file pFilePath to (specialFolderPath("trsh") & "/" & tFile)
end TrashIt

Original version posted 5/18/2006 by Sarah Reichelt to the Use-Revolution List, modified 9/27/2006 by Ken Ray


 Print this tip

News and Rumors Products Services Developer Resources Contact STS About STS