"Can’t make \"x\" into type boolean." number -1700 from "x" to boolean

Pleas help cant make this simple script work:


set myFolder to (choose folder with prompt "choose the main folder")
tell application "Finder"
	set myfiles to get name of every item of (entire contents of folder myFolder) as list
	repeat with i from 1 to count of items in myfiles
		set y to item i of myfiles as text
		set newlist to newlist and y
	end repeat
	
	log newlist
end tell

Two changes were needed.

set myFolder to (choose folder with prompt "choose the main folder")
set newList to {} # ADDED
tell application "Finder"
	set myfiles to get name of every item of (entire contents of folder myFolder) as list
	repeat with i from 1 to count of items in myfiles
		set y to item i of myfiles as text
		set newList to newList & y # EDITED
	end repeat
	
	log newList
end tell

(1) You failed to define the variable newList
(2) You tried to use the Boolean operator AND where you had to use the concatenate (&) one.

For my own use, as I am lazy I would code :
[format]set end of newList to y[/format]

Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) mardi 29 novembre 2016 18:19:36

Hi Brian.

  1. There’s nothing in the script showing that newlist has been previously set, so you can’t use it in its own redefinition.
  2. ‘and’ is a operator which acts on booleans. I suspect you actually mean the concatenation operator ‘&’'.

Thanks! :smiley:

@Brian, practically you are creating the list twice, once in the “entire contents” line and in the repeat loop.

This does the same as your script

set myFolder to (choose folder with prompt "choose the main folder")
tell application "Finder"
	set newList to name of every item of (entire contents of myFolder)
	log newList
end tell