FileManagerLib how to copy filenames with spaces

I am trying to copy a file whose path has spaces in it, and I can’t figure out how to do it.

-- Proof of concept, not the final code
repeat with theline in thelist
	set z to the theline -- just for diagnostic purposes
       -- example item 1 contents "23e2df087376f1cdb8b86ca1dd28084b /Users/name/Library/Mail/V8/19D44A4B-70C9-48D4-9CEA-0783B4E1C47A/Mailboxes.mbox/AAF old messages.mbox/35D025FF-59CF-4499-8B42-AC3255CD70BF/Data/1/8/8/Messages/881435.emlx"
	-- remove the initial md5 hash
    set atid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to " "
	set thefile to text items of theline
	set thefile to items 2 thru (count of thefile) of thefile
	set thefile to thefile as text
	set AppleScript's text item delimiters to atid
        -- thefile ends as "/Users/name/Library/Mail/V8/19D44A4B-70C9-48D4-9CEA-0783B4E1C47A/Mailboxes.mbox/AAF old messages.mbox/35D025FF-59CF-4499-8B42-AC3255CD70BF/Data/1/8/8/Messages/881435.emlx"

	set sourceFile to thefile
	set destFolder to "~/deleted mail/"
	set destName to "myname.eml"
	
	copy object sourceFile to folder destFolder new name destName with replacing and return path
end repeat

thelist has a series of lines with the first element being an md5 hash, followed by the file pathname, which happens to have spaces in the path.

If I set sourceFile to thefile as above, copy fails because the last element in the path (i.e. the actual filename) does not exist. If I use quoted form, then copy fails because the full path (with single quotes around) does not exist. I have copied the failing path the terminal, and it works there.

FileManagerLib v2.3.5
Mac OS X 11.6.7
Script Debugger v8.0.10

I’m not sure I follow, but you shouldn’t be using the quoted form.

@ShaneStanley Thanks for the reply, and sorry if I was not clear.

If I don’t use the quoted form and just pass:

into the FileManagerLib copy, the script fails with “The file “881435.emlx” doesn’t exist.”, so it seems to have stripped off the rest of the path. The file is definately there, if I copy the full path from script debugger to terminal, ls finds it OK.

I wonder if it’s actually a permissions issue. Try with a file somewhere like a Desktop folder and see what happens there.