Hey gang
Its me again, asking for some help I’ve got most of the kinks worked out of my main script, but i’m working on a few secondary scripts, to help the user.
My first is an import script, so that the user can target the script that they want to use, and import it into the scripts folder. I would like 3 ways of doing this, which I have, but only 1 works. Those 3 ways are Alias, Copy, and Move. Alias, due to the fact that by doing that, entire games can be imported into the folder and run using this script. (I.E- make an alias of “Medal of Honor” for example, and that alias can be launched from the script). Copy, in case the script in question happens to be a bundle, in which case an alias won’t work, or Move, which just moves the script itself into the folder.
As of now, only move works.
Alias returns an error saying that you can only make aliases of folders and disks, so i’m thinking I havn’t got the correct syntax there.
Copy correctly duplicates the file, but fails to move it into the folder. It also, as a side effect, names the resulting file wish a “copy” at the end. I can think of one way that could be solved, but its not ‘optimal’ so if any of you know how to change its name back to its orginal name after its imported, that would be much appreciated.
Now then, my script (I will come up with some more creative naming schemes before I release this thing :P)
--path to Myscripts
set mypath to (path to me)
tell application "Finder"
set Myscripts to (container of mypath) as string
set scriptsfolder to (Myscripts & "Myscripts") as alias
end tell
--main script
tell application "Finder"
display dialog "How do you wish to import your Script or Application?" buttons {"Alias", "Copy", "Move"} default button 2
if button returned of the result is "Alias" then
set thescript to choose file with prompt "Select yourscript"
set thealias to (make alias of thescript)
move thealias to folder scriptsfolder
else
if button returned of the result is "Copy" then
set thescript to choose file with prompt "Select your script"
set thecopy to (make (duplicate of thescript))
move thecopy to folder scriptsfolder
else
if button returned of the result is "move" then
set thescript to choose file with prompt "Select your script"
move thescript to folder scriptsfolder
end if
end if
end if
end tell
The other question, unrelated to this script, is how to check a folder to be sure it doesn’t contain any disallowed filetypes. (I.E- make sure that only .scrpt or .app files are in the folder, not .png, or .gif, or .dmg or whatever else)
Thanks again