Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Applescript Duplicate Files Error

Applescript Duplicate Files Error
Thread Tools
pacificlucy
Fresh-Faced Recruit
Join Date: Apr 2007
Status: Offline
Reply With Quote
Apr 8, 2007, 08:59 PM
 
Hi all-

Any help with this will be much appreciated - I've been banging my head against this all day and I know it must be something very simple.

All I'm trying to do is duplicate a file from one location to another, using applescript. Everytime I run my script, I get an AppleScript Error:

"Finder got an error: Can't set folder "/Users/Brock/Documents/" to file "/Users/Brock/lucy.jpg"."

Below is a copy of my script. There are three different ways of copying I've tried, and each fails the exact same way. What could be going on? It's driving me nuts!

-------------------

set ExportFolder to "/Users/Brock/Documents/"
set PictureThing to "/Users/Brock/lucy.jpg"

tell application "Finder"
do shell script ("cp " & (quoted form of POSIX path of PictureThing) & " " & quoted form of POSIX path of ExportFolder)

duplicate file PictureThing to folder ExportFolder

duplicate file "/Users/brock/lucy.jpg" to folder ("/Users/brock/Documents/")

end tell
     
itai195
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
Apr 12, 2007, 12:56 AM
 
You need to use aliases, not POSIX style paths. This will work:

set PictureThing to alias ((path to home folder as text) & "lucy.jpg")

tell application "Finder"
duplicate PictureThing to path to documents folder
end tell

I'm surprised the do shell script command didn't work for you, it works on my system. However, saying 'POSIX path of' a reference that's already in POSIX style is unnecessary.
( Last edited by itai195; Apr 12, 2007 at 01:03 AM. )
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 03:36 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,