How to Move an App

Hi, Can anyone tell me how to move an app to another location? In Realbasic I used the following code but it no longer does the job. I assume that the Application folder is treated differently under OS 10.7 and up, and perhaps its contents cannot be moved so simply.

Any ideas? Thanks.

dim f as folderitem
f = SpecialFolder.Applications.child(“Appname.app”)
f.MoveFileTo SpecialFolder.Trash

That really should never have worked…
APP is really a folder (OSX tricks you into thinking otherwise)
and you cannot delete a FOLDER that has files in it… and an APP bundle has LOTS of files

you need to recurse thru the bundle (and its internal directories) remove all the files, then remove all the subdirectories, THEN delete the APP bundle directory.

[quote=108201:@Stan Mathews]Hi, Can anyone tell me how to move an app to another location? In Realbasic I used the following code but it no longer does the job. I assume that the Application folder is treated differently under OS 10.7 and up, and perhaps its contents cannot be moved so simply.

Any ideas? Thanks.

dim f as folderitem
f = SpecialFolder.Applications.child(“Appname.app”)
f.MoveFileTo SpecialFolder.Trash[/quote]

dim f as folderitem f = SpecialFolder.Applications.child("Folx.app") f.MoveFileTo(SpecialFolder.Trash)

This works. Do not forget the parenthesis for f.MoveFile()

Seems the system does not require any special authorization to move an app to the trash under 10.9.4, at least if the user has enough privileges.

Thanks Dave for your quick feedback. I can easily move folders that are loaded with various files (not just to the trash, but to any location). It just doesn’t work with Appname.app. I’m thinking there must be a simple way of moving an app to a different folder without having to go through all its contents one piece at a time. Or…perhaps there isn’t?

Thanks, Stan. That did the trick.

Dave’s right, you can’t delete a folder with files in it, but Stan’s code moves the folder to the trash, which seems to work (as it doesn’t actually delete the folder).