Just to let you know, when testing FileManagerLib, I found an tiny issue:
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
use FMLib : script "fileManagerLib"
set aFileOrPath to "~/Desktop/testFile.rtf" -- edited after Yvan's comment
set folderOrPath to "~/Desktop/testFolder4"
FMLib's copyItem:aFileOrPath uniquelyToFolder:folderOrPath
The result was an error because the destination folder was misspelled (It should be testFolder).
But the error returned was: The file “testFile” does not exists.
Every handler that uses copyFromURL or moveFromURL has the same behavior.
I’m not acustomed to this list and don’t own Script Debugger so I don’t know how to insert a script the pretty way.
Here are my comments
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
use FMLib : script "fileManagerLib"
--set aFileOrPath to alias "~/Desktop/testFile.rtf" # **alias of a Posix path doesn't make sense**
set aFileOrPath to "~/Desktop/testFile.rtf" # **Here is the correct syntax**
set folderOrPath to "~/Desktop/testFolder4" # **the folder must be available**
FMLib's copyItem:aFileOrPath uniquelyToFolder:folderOrPath
Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) lundi 12 septembre 2016 17:38:51
I know that. The word alias is residual from the original script.
I’m going right now to edit my precedent post.
Which script runs fine if the destination name is not misspelled.
The error has to be there. It’s it contents the problem.
Just insert [&code&] at start and “[&/code&]” at end (delete every “&”).
The link foe opening in SD is automatic.
I’m not sure what your problem is. Is the use of file instead of folder? Because these error messages are generated by the OS, and at this level everything is a file.
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
use FMLib : script "fileManagerLib"
set aFileOrPath to "~/Desktop/differentName.rtf"
set folderOrPath to "~/Desktop/testFolder4"
FMLib's copyItem:aFileOrPath uniquelyToFolder:folderOrPath
The file “differentName.rtf” exists on the desktop.
And, on the desktop, there is a folder named “testFolder”.
If the folder’s name is nor misspelled, there’s no error and the file is copied in the folder “testFolder”.
But if (like in my script example) the folder’s name is misspelled, there’s an error saying:The file "differentName.rtf" does not exists
Where it should be: The file "testFolder4" does not exists.
In short, the problem is not the term file but the Finder item the error is returning.
OK, now I see. It’s still a Cocoa problem – here’s the error it generates:
(NSError) Error Domain=NSCocoaErrorDomain Code=4 "The file “Errors.rtf” doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/shane/Desktop/Errors.rtf, NSUserStringVariant=( Copy ), NSDestinationFilePath=/Users/shane/Desktop/testFolder4/Errors.rtf, NSFilePath=/Users/shane/Desktop/Errors.rtf, NSUnderlyingError=0x618005a4c8d0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
It’s seeing there’s an invalid path, but it’s not figuring out why, and more importantly it’s not actually including the path in the localized error message.