Error "Can’t make every file of..into type alias list" please help!


I am trying to adapt a script that uses Max (an audio conversion tool) to convert files in a folder to another format. The original script which I found on a forum asked the user to choose the folder with the files in which need to be converted, but I want to specify the folder in the script so that it can be automated. So I changed the line:

set sourceFolder to choose folder


set sourceFolder to "Macintosh HD:Users:nick:Desktop:test:"

However I then get the error (this is the only line in the script I changed and the original script works fine):

error “Can’t make every file of "Macintosh HD:Users:nick:Desktop:test:" whose name extension = "m4a" into type alias list.” number -1700 from every file of “Macintosh HD:Users:nick:Desktop:test:” whose name extension = “m4a” to «class alst»

Could someone let me know why I am getting this error and how I can sort it. The full script is below.



tell application "Max" to activate
tell application "Finder"
	set sourceFolder to "Macintosh HD:Users:nick:Desktop:test:"
	set theFiles to (every file of sourceFolder) as alias list
	repeat with aFile in theFiles
		tell application "Max"
			convert aFile
		end tell
		delay 1
		tell application "System Events"
			tell process "Max"
				click button "Convert" of tool bar of window "File Conversion"
				set encoderOpen to true
				repeat while encoderOpen is true
						window "Encoder"
					on error
						set encoderOpen to false
					end try
				end repeat
			end tell
		end tell
	end repeat
end tell


choose folder returns an alias specifier,
¢ so either you coerce the literal string path to alias

set sourceFolder to "Macintosh HD:Users:nick:Desktop:test:" as alias

(it’s better to use a relative path so the script can run on any Mac

set sourceFolder to ((path to desktop as text) & "test:") as alias


¢ or add the keyword folder

set theFiles to (every file of folder sourceFolder) as alias list

many thanks Stefan. that works fine. Nick