Conflict with Foundation Framework

If I have “Foundation” in the scripts framework dependencies, this code returns the dialog “Can’t make current application into type file” and ends the script. The script runs successfully without the Foundation framework.

I’m halfway through troubleshooting the code, but haven’t identified which part is causing the error. I ran into some issues the other day with AVFoundation/AVFAudio which were Catalina specific, could this be OS related? If not, any idea how I might be able to work around it?

The code works independently and doesn’t rely on the rest of the script to run, I’d rather not delegate it to another script.

Any advice would be greatly appreciated

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

property sourceFile : ((path to desktop) & "output.txt") as string
property dataFolder : ((path to desktop) & "dataFolder:") as string
property destFolder : ((path to desktop) & "./tempCsv:") as string

	set copyList to {}
	set suffixList to paragraphs of (read file sourceFile)
	set csvList to list folder dataFolder without invisibles
	repeat with n from 1 to count (csvList)
		set thisCsv to item n of csvList
		set fileRef to alias (dataFolder & thisCsv)
		repeat with suffixName in suffixList
			if (suffixName as string) is in thisCsv then
				set end of copyList to fileRef
				exit repeat
			end if
		end repeat
	end repeat
	display dialog "Analysis Complete, preparing " & return & (count copyList) & " references to be processed "
	tell application "Finder"
		duplicate copyList to folder destFolder
	end tell
end try

Model: 2019 2.9 or something xeon core 16gb
AppleScript: Script Debugger 8
Browser: Safari 605.1.15
Operating System: macOS 10.15

Its seems the specifier “file” in the read command is whats causing the conflict.

I’ve tried a few other things inncluding a suggestion from SD forum to use: “(read “variable” as «class furl»)” but on run either the script immediately stops or says “Can’t make “Mojave:Users:dh:Desktop:output.txt” into type file.”

First off, this is not a good idea. You’re coercing two items to a string, which means using whatever the value of text item delimiters is as that point. Use “property sourceFile : ((path to desktop as text) & “output.txt”)”

Two things to try.

First, use this approach:

property sourceFile : ((path to desktop as text) & "output.txt")
set sourceFile to sourceFile as «class furl»
set suffixList to paragraphs of (read sourceFile)

Note the word file has to be removed.

If that fails, try with a file not on the desktop, to check it’s not a permissions problem.

Oh, and a third: remove that try block when testing. It only makes it harder to track down what’s happening.

Thanks very much Shane, it works great. I thought I was going to have to use mdfind but the search cross referenced 200 files against 3000 in just over 10 seconds Not bad at all.

Thanks again!


Another reason it’s not a good idea is that by making ‘sourceFile’ a property, you’re setting it to the path at the time you compile the script rather than the path at the time the script’s run. If you later want to run the script in a situation where the disk or user names are different, you’ll have to recompile it before it will work. It’s better to use path to desktop at run time instead:

-- property sourceFile:((path to desktop as text) & "output.txt") -- Ditch this.

set sourceFile to ((path to desktop as text) & "output.txt") as «class furl»

Great, ok. Thank you Nigel!