I’m writing what should be a simple script, but I’m obviously missing something between renaming & revealing the file (I haven’t spent much time with duplicating files w/applescript). I have simplified my script, because it will be triggered within a FileMaker Database, and am using the reveal just for testing –
set testFileOld to POSIX file "/Users/schuylerjohnson/Desktop/duplication test/testfile.rtf"
set testFileNewName to "testfile2.rtf"
tell application "Finder"
set testFileNew to duplicate file testFileOld
set name of testFileNew to testFileNewName
reveal testFileNew
end tell
The issue is AppleScript is trying to reveal “testfile copy.rtf”, not “testfile2.rtf”!
“error “Finder got an error: Can’t get document file "testfile copy.rtf" of folder "duplication test" of folder "Desktop" of folder "schuylerjohnson" of folder "Users" of startup disk.” number -1728 from document file “testfile copy.rtf” of folder “duplication test” of folder “Desktop” of folder “schuylerjohnson” of folder “Users” of startup disk”
What step am I missing so that “testFileNew” becomes associated with “testfile2.rtf” rather than “testfile copy.rtf” ?
Thank you guys!