Vinny
Vinny

Reputation: 309

Moving a File with AppleScript

Today is my first day of even knowing AppleScript exists so I apologize if this is a stupid question. I've searched and can't find the answer on how to simply move a file with AppleScript

All I need to do is move a file from ~/Downloads/blank.potx to ~/Library/Application Support/Office/User Templates/My Templates

This is what I have in AppleScript right now:

tell application "Finder"
     move "~/Downloads/blank.potx" to "~/Library/Application Support/Microsoft/Office/User Templates/My Templates/blank.potx"
end tell

When I run this it gives me an error:

error "Finder got an error: AppleEvent handler failed." number -10000

Again, first day using AppleScript and I'm lost. Any help you can provide would be awesome.

If there's a better way to do this please let me know as well.

Thanks!

Upvotes: 1

Views: 893

Answers (1)

jweaks
jweaks

Reputation: 3792

Search is your friend. You can easily find the syntax on stack overflow. Such as here:

tell application "Finder"
    move POSIX file "/Users/xx/Documents/img.jpg" to POSIX file "/Users/xx/Documents/State" with replacing
end tell

If you're gonna use Posix file paths, you need to indicate so, and you need to name the string as a file.

Upvotes: 1

Related Questions