How to make a list of file aliases after choose folder

set myFolder to choose folder with prompt "Choose the folder:"
tell application "Finder"
	set theList to list folder myFolder
	repeat with f in theList
		
		set theinfo to info for f  -- here things go wrong, cant get info...
		-- other statements using info...

	end repeat
end tell

I know what goes wrong: f is not an alias, but how do I force it to become an alias?
theList is wrong allready: it contains filenames, not complete paths or aliases.

Got it! I don’t know if this is the “official” way but it works!

set myFolder to choose folder with prompt "Choose the folder:"
tell application "Finder"
   set theList to (every item of folder myFolder) as alias list
   repeat with f in theList
      
      set theinfo to (info for f)
      
   end repeat
end tell

Hi DutchVince,

‘list folder’, ‘info for’, etc. are standard addition commands. You try to keep standard addition commands out of tell blocks in possible. If you want to use ‘list folder’, then you don’t need the Finder and something like this would work:

set f to (choose folder)
set i_list to (list folder f without invisibles)
if i_list is {} then
beep 1
return
end if
– remove dot files
set mod_list to i_list
repeat with i in i_list
if i begins with “.” then
set mod_list to (rest of mod_list)
else
exit repeat
end if
end repeat
if mod_list is {} then
beep 2
return
end if
– get info
repeat with i in mod_list
set i_path to (f & i) as string
set i_info to (info for alias i_path)
end repeat

The main thing with the above is those dot files causes errors.

If you use the Finder, then coercing to alias list will cause an error if the folder has only one item (i.e. you can’t coerce a reference to alias list). You can only coerce a multithreaded list to alias list. Something like this:

set f to (choose folder)
tell application “Finder”
– if f has only 1 item then coercion to alias list will error
try
set i_list to (every item of f) as alias list
on error
set i_list to ((every item of f) as alias) as list
end try
properties of (item 1 of i_list) – getting info for the first item in i_lilst
end tell

Note you can get properties of items in the Finder and coercion to alias list in not necessary. You might also run into trouble when using lists created with Finder alias list in other scriptable applications. So if I need a list of aliases, then I usually don’t use the Finder.

Just in case you get errors working with this. It can be confusing.

gl,

So if you wanted just the properties of items you can use the every element reference form with properties:

set f to (choose folder)
tell application “Finder”
set item_infos to (properties of every item of f)
end tell

gl,

Thanks, Kel.

Interesting and usefull!