Simple sample script only worked once

I’m having lots of problems getting even the simplest script to work.
This was an example taken from this board, I think.

I finally got it to run but only once. When I move the items back and run it again it gives this error.

error “Finder got an error: The operation can’t be completed.” number -8082

Could someone please enlighten me? I am a complete noobie but have been referring to three PDFs on applescripts and keep getting stumped.

tell application "Finder"
	set a to folder "Macintosh HD:Users:Rob:Desktop:Scripts"
	set b to folder "Macintosh HD:Users:Rob:Desktop:Scripts2"
	move every file of a to b
end tell

Thanks Tom,
What I’m trying to do is learn Applescript and I really want to know what’s going on and why it worked once but doesn’t work anymore.
Thanks again.
Cheers
Rob

Try using the following switches

Try and end try, this will catch what / why something is not happening

e.g



tell application "Finder"
   set a to folder "Macintosh HD:Users:Rob:Desktop:Scripts:"
   set b to folder "Macintosh HD:Users:Rob:Desktop:Scripts2:"

  Try

   move every item of a to b

  End Try


end tell


Then check your results / replies and events tabs to see what information is brought back

Jay

Hi Tom,
Yes I’m using Snow Leopard as well. I assume you tried it more than once. Computers, sometimes they baffle me.

Thanks Jay, I’ll give it a go when I get home from work today.
Cheers
Rob

Hi Jay,
I ran that script and here is the reply. Does it give you any hints?

tell application “Finder”
get folder “Macintosh HD:Users:Rob:Desktop:Scripts:”
→ folder “Scripts” of folder “Desktop” of folder “Rob” of folder “Users” of startup disk
get folder “Macintosh HD:Users:Rob:Desktop:Scripts2:”
→ folder “Scripts2” of folder “Desktop” of folder “Rob” of folder “Users” of startup disk
move every item of folder “Scripts” of folder “Desktop” of folder “Rob” of folder “Users” of startup disk to folder “Scripts2” of folder “Desktop” of folder “Rob” of folder “Users” of startup disk
→ current application
→ error “The operation can’t be completed.” number -8082
end tell

Cheers
Rob

hi rob,

i can’t test it in snow leopard, but your script in the first posting should work.

try

try
	-- insert actions here
on error the error_message number the error_number
	display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try

and

have a look at http://macscripter.net/viewtopic.php?id=30109

for detailed information.

you may add a “with replacing” to the movecommand to overwrite existing files …

Thanks Hans but my error code -8082 is not recognised.
Thanks again
Cheers
Rob

Ok The System cannot find your stated Folders

Try Not to Use The USERS call as this makes the script specific to yourself

Also if you change the Name of Your Harddisk This is not going to work as you have specified it’s name

try This



do shell script "cp -R $HOME/Desktop/Scripts  /$HOME/Desktop/Scripts2/"


The CP = Copy
The R - Mean With Folders & Files - It Keeps The Structure
$HOME = You Home Drive e.g Jay/Documents

Or There are other Ways:



set a to folder "$HOME/Desktop/Scripts/"
set b to folder "$HOME/:Desktop:Scripts2/"

move every item of a to b




If you do choose to use the : : Method



set a to (path to home folder as text) & ":Desktop:Scripts"
set b to (path to home folder as text) & ":Desktop:Scripts2"

move every item of a to b




let me know the outcome, am at work on a Windows Machine at Momment :frowning:

it seems that the error comes from the script running environment (current application), not from AppleScript itself.
The code is absolutely correct

Hi Jay, Thanks.
The first script works copies the folder Script and its contents to Script2.
The second script doesn’t compile “expected end of line where first quote mark (”) is.
The third one runs with the following error -
error “Can’t make {"M", "a", "c", "i", "n", "t", "o", "s", "h", " ", "H", "D", ":", "U", "s", "e", "r", "s", ":", "R", "o", "b", ":", ":", "D", "e", "s", "k", "t", "o", "p", ":", "S", "c", "r", "i", "p", "t", "s"} into type reference.” number -1700 from {“M”, “a”, “c”, “i”, “n”, “t”, “o”, “s”, “h”, " ", “H”, “D”, “:”, “U”, “s”, “e”, “r”, “s”, “:”, “R”, “o”, “b”, “:”, “:”, “D”, “e”, “s”, “k”, “t”, “o”, “p”, “:”, “S”, “c”, “r”, “i”, “p”, “t”, “s”} to reference

Jay I really appreciate your help and I will persue this in the morning. It’s past midnight here, Friday night and I’m almost asleep.
Thanks again I’ll check out your response in the morning.
Cheers and thanks again
Rob

No Probs EBoof, Will Check These Through When I Get Home and Post Up Later Tongiht (its 2pm Here), or Sometime Saterday

You forgot the tell “Finder” instructions and to pass the instruction to folders (in the script, you pas it to strings)


set a to (path to desktop folder as text) & ":Scripts"
set b to (path to desktop folder as text) & ":Scripts2"

tell application "Finder"
	move every item of folder a to folder b
end tell

would work.

Yvan KOENIG (VALLAURIS, France) samedi 13 novembre 2010 11:08:56

Thanks Yvan,
But I still get an error. I deleted the colon before “Scripts” in your script but then get this error.

tell current application
path to desktop as text
→ “Macintosh HD:Users:Rob:Desktop:”
path to desktop as text
→ “Macintosh HD:Users:Rob:Desktop:”
end tell
tell application “Finder”
move every item of folder “Macintosh HD:Users:Rob:Desktop:Scripts” to folder “Macintosh HD:Users:Rob:Desktop:Scripts2”
→ current application
→ error “The operation can’t be completed.” number -8082
Result:
error “Finder got an error: The operation can’t be completed.” number -8082

So I’m still at a loss.
Cheers
Rob

Remove the : before the scripts

WOrks Fine On My Machine:



set a to (path to desktop folder as text) & “Scripts”
set b to (path to desktop folder as text) & “Scripts2”

tell application “Finder”
move every item of folder a to folder b
end tell



HI Jay,
As I said in my previous post I did remove the :.
I still get the above error and I don’t know why.
As Stefan pointed out the error is returned bu the current application. Is there a way to query the system to find out what the current application is?
Cheers
Rob

Hey eBoof

I just ran my script in the last post and i worked fine, no issues.

Are there any files that you are trying to copy that you have no rights to?

Are you a standard / admin user - not sure if this will make a difference

Re the : point, i was quoting the script in the thread above, it wouldn’t work due to Yvan leaving the : in the wrong area

What files do you have in that folder??, Do you have any running applications from that folder?

Hi Jay,
Gee you’re quick. You must have replied while I was quickly editing my post.
Anyway, I renamed my old “Script” folder on the desktop, created a new Folder called “Script” copied one file into it and checked my User account. I am using the Adminstrator account and I still get the message in my previous post.
I’m sure this is going to be something simple.
Is there a way to determine whatthe current application is that is giving me the 8082 error?
Cheers
Rob

Not sure on the answer to current application and seeing what it is exactly, am working on that one.

To make sure i have a perfect test scenario

What OSX are you running?

Are you running this in Applescript or via an XCode app

What Files are you trying to move from a to b

Can you also try this, over where it says current application can you hover your mouse until it becomes a tool tip it may state current application in there…

e.g Run Script, Get Error,

Click Events, Now Find where it says current application, hover mouse over.
Cheers

Thanks Jay
OS is Snow Leopard 10.6.4
Applescript Editor 2.3 (118)
Applescript 2.1.2
and one pdf file.
The rollover for current application doesn’t specify it but the rollover on the resulting error says the Finder got an error (Thanks for that). Any way to copy tips to Clipboard so I can include in posts?
When we figure this out I know we’ll kick ourselves.
Cheers
Rob