ppseprus
ppseprus

Reputation: 548

Applescript's 'move folder' issue

First of all, I do not understand why the move folder command does not remove the source on finish.

In an automation, I want to move folders. Since the move folder command does not remove the source, I have to add the delete command as well. For some reason, however, if the size of the folder is like 3GB, the script returns with the 'The action “Run AppleScript” encountered an error.' message.

I click 'ok' and move folder command finishes up, while the delete does NOT. Does anyone know why?

See below:

tell application "Finder"
    move f to dest
    delete f
end tell

FYI: The above code works fine when running on small folders (like 200Mb)

Upvotes: 0

Views: 137

Answers (1)

McUsr
McUsr

Reputation: 1409

When done correctly, the folders you move, will be moved, you should not have to delete them afterwards, at least this is how it worked up to Mavericks.

 set desktopHFS to (path to desktop folder as text)
 tell application "Finder"
    set moveTarg to folder (desktopHFS & "MoveFolderTest")
    set moveDest to folder (desktopHFS & "Junk")
    move moveTarg to moveDest replacing no
 end tell

I have never tried to move folders of that size, and probably never will with AppleScript. I'd rather use the mv command of the shell. Apart from that, I believe! the reason it doesn't work, is that the initiating AppleEvent times out before Finder reports "all done" to your script.

I'd try something like this, and maybe add to the time, until the move operation can be done within the limits of it.

I also thought that move

 with timeout of 600 seconds -- 10 minutes, maybe you need more!
    try

        tell application "Finder"
            move f to dest
            delete f
        end tell
    on error e number n
        tell application (path to frontmost application as text)
            display alert "Error during move" & ":
" & e & " #: " & n
        end tell
    end try
 end timeout

Upvotes: 1

Related Questions