Error message when using FileManagerLib

finder
foundation
asobjc

(Jonas Whale) #1

@ShaneStanley

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.

:wink:


(Shane Stanley) #2

Are you sure it wasn’t file testFolder?


(Jonas Whale) #3

No, no. The names here are for convenience.
In the real script they was very different.


(koenigyvan) #4

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 :slight_smile:

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


(Jonas Whale) #5

Bonjour Yvan,

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.

:wink:


(Shane Stanley) #6

Just type three backticks (`) on the line before and again on the line after. I’ve added them to your post above, which you can see if you edit it.


(Shane Stanley) #7

If you don’t have Script Debugger, it will open in Script Editor.


(Shane Stanley) #8

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.


(Jonas Whale) #9

Ok. Let’s start again.

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.

:wink:


(Shane Stanley) #10

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.

It’s probably worth logging a bug about.


(Jonas Whale) #11

Ok, I’ll do it… If only I have a link!

:wink:


(Shane Stanley) #12

http://bugreport.apple.com

You need a developer account.