What is this error and how do I fix it: Finder got an error: Can’t make class file

Viewed 35

I've just started out with AppleScript and I am trying to make a "new text file" thing in Automator. I keep getting this error: "Finder got an error: Can’t make class file."

Here is my code:

tell application "Finder"
    set filename to display dialog "Enter Filename" default answer "newfile"
    make new file at (target of front window) with properties {name:text returned of filename, file type:text}
end tell```
1 Answers

A get statement is usually optional, but in this case it is needed in order to evaluate the location specifier, since the statement is in the middle of the make command - see the AppleScript Language Guide. For example:

   make new file at (get target of front window) …

You can also evaluate the location specifier using a separate statement:

   set destination to target of front window
   make new file at destination …
Related