Maciek Czarnik
Maciek Czarnik

Reputation: 6181

AppleScript tell Finder move -10000 Error "Handler can’t handle objects of this class"

I've created directory structure and placed the a file in A directory:

~/A
~/B

In AppleScript I'm trying to move file a from A to B. Here is my code:

on run

    tell application "Finder"
        move POSIX file "~/A/a" to POSIX file "~/B"
    end tell

end run

But when I run the script I get error:

error "Finder got an error: Handler can’t handle objects of this class." number -10000

This is simplified version of my problem. Can anybody help me please?

Upvotes: 3

Views: 3034

Answers (1)

adayzdone
adayzdone

Reputation: 11238

Try:

set myFile to POSIX file (POSIX path of (path to home folder) & "A/a.txt")
set myFolder to POSIX file (POSIX path of (path to home folder) & "B")
tell application "Finder" to move myFile to myFolder

Or:

set myFile to (path to home folder as text) & "A:a.txt"
set myFolder to (path to home folder as text) & "B"
tell application "Finder" to move myFile to myFolder

Upvotes: 5

Related Questions