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
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
@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