Wednesday, June 3, 2020

#1 2020-03-25 10:08:56 pm

TheIaMonLyOneHeRe
Member
Registered: 2018-09-16
Posts: 41

How to move App to Applications folder when running it?

What I'm trying to do is that when the user runs the App from outside the Applications folder, a display alert appears asking if he wants to move the App to the Applications folder if the App is not already there. I tried the following:

Applescript:

tell application (path to frontmost application as text)
set myApp to path of document 1
set folderApplications to "/Applications" as POSIX file
set anyApp to "/Applications/My.app" as POSIX file
tell application "Finder"
if exists anyApp then
display alert "There is already an App with the same name in Applications Folder.
return
else
tell application "
System Events"
move myApp to folderApplications
end tell
end if
end tell
end tell

but I get the following error: ERROR: Can’t get «class FTPc» of document 1. (error -1728)
Note: In the Script Editor it works well.

Last edited by TheIaMonLyOneHeRe (2020-03-25 10:10:08 pm)

Offline

 

#2 2020-03-26 12:43:48 am

maro
Member
From:: Nerima, Tokyo, Japan
Registered: 2004-05-30
Posts: 103
Website

Re: How to move App to Applications folder when running it?

The property label to obtain file path of a document is not only a "path" but also a "file" and so on.

Applescript:


--Script Editor
document -- A document.
   path Unicode text -- The document's path.

--Keynote
document -- A document.
   file (r/o) file -- Its location on disk, if it has one.

--Mail
document -- A document.
   file (r/o) file -- Its location on disk, if it has one.

If I make the solution, I'll write it as following.

step 0: Quit all running applications
step 1: Find application file outside /Application folder by spotlight
step 2: Display found path(s) with Finder or dialog
step 3: (move application files by hand or script)


I wrote thousands of AppleScript to realize my idea. Natural language interface, voice recognition commander and so on. Though my mother toungue is strange language, Japanese, my most frequently write language is AppleScript. I believe it is for making things easy and powerful.

Offline

 

#3 2020-03-27 07:38:44 am

TheIaMonLyOneHeRe
Member
Registered: 2018-09-16
Posts: 41

Re: How to move App to Applications folder when running it?

Thanks for the suggestion I will try something, but if you can post an example it would be excellent,

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)