Newbee, moving a file: does not work

Hi,
i have a template file which i would like to copy and then open automatically, i started with this script:

tell application "Finder"
	move file ¬
		"Autoload template" of folder "Logic 6 Series" of folder "Applications" to folder "New Projects" of folder "Acustudio" of disk "PRODUCTION:"
end tell

But i ge this error:
“Finder got an error: Can’t get file “Autoloadt emplate” of folder “Logic 6 Series” of folder “Applications”.”

Thanks.

Someday,
I hope this might get you started. As your code :

tell application "Finder" 
   move file ¬ 
      "Autoload template" of folder "Logic 6 Series" of folder "Applications" to folder "New Projects" of folder "Acustudio" of disk "PRODUCTION:" 
end tell 

tells the finder to move autoload template to where… that is a good question. That’s one of your errors. But there is more to learn too. I just had some one help me with this so here is some code that might help you out moving files thru applescript.


tell application "Finder"
	set thefile to (choose file) -- select the file you want to move
	set dest_folder to (choose folder) -- select the destination folder
	move file thefile to folder dest_folder -- this should get your file moved
end tell

Keep it coding,

Krazay
8) PS. I’m not an expert but my buddies here might help you out more if I made a mistake

Thanks Krazay, now the error seems of another kind (permissoins?)

 Can't get "Autoload" of folder "TEMPLATES" of disk "RD". Access not allowed.

…Access not allowed…?

Then i tried this:

tell application "Finder"
	set thefile to "RD:TEMPLATES:Autoload muovere"
	set dest_folder to folder "PRODUCTION:Acustudio:Prove OK:"
	move file thefile to folder dest_folder
end tell

And i get this error:

tell application "Finder"
	get folder "PRODUCTION:Acustudio:Prove OK:"
		folder "Prove OK" of folder "Acustudio" of disk "PRODUCTION"
	move file "RD:TEMPLATES:Autoload muovere" to folder (folder "Prove OK" of folder "Acustudio" of disk "PRODUCTION")
		"Finder got an error: Can't make some data into the expected type."

Someday,
I hope someone else here might more about permissions that I. That’s what it sounds like, permissions. Good luck!

Krazay

As I expect you’ve realised by now, you should have included the source disk in the Finder reference for the file you want to move. Assuming you “Applications” folder is the main one on your startup disk, an easy way to get it is to use ‘path to’:

set appsFolder to (path to "apps" from System domain) -- gets an alias to the Applications folder
tell application "Finder"
  move file ¬
    "Autoload template" of folder "Logic 6 Series" of appsFolder to folder "New Projects" of folder "Acustudio" of disk "PRODUCTION:"
end tell

Since both ‘choose file’ and ‘choose folder’ return aliases, there’s no need to use the keywords ‘file’ and ‘folder’ in the ‘move’ line.

  1. This is a different file from the one above, so the presumably the error’s not occuring in the same place. Or what? Certainly not as a result of Krazay’s suggestion.
  2. It’s a compilation error caused by not using an appropriate keyword (probably ‘file’) in front of the name “Autoload”.

By setting dest_folder to ‘folder “PRODUCTION:Acustudio:Prove OK:”’, you’re setting it to a Finder reference, so you should not put the keyword ‘folder’ in front of it in the following line. On the other hand, you’ve simply set thefile to the string “RD:TEMPLATES:Autoload muovere”, so it’s correct to use ‘file thefile’ in the ‘move’ line, because that’s what turns it into a Finder reference. It would be less confusing to use the same convention for both the file and the folder:

-- Either:
tell application "Finder"
   set thefile to file "RD:TEMPLATES:Autoload muovere"
   set dest_folder to folder "PRODUCTION:Acustudio:Prove OK:"
   move thefile to dest_folder
end tell

-- Or:
tell application "Finder"
   set filePath to "RD:TEMPLATES:Autoload muovere"
   set dest_Path to "PRODUCTION:Acustudio:Prove OK:"
   move file filePath to folder dest_Path
end tell