choose folder problems (file type and posix path)

I want to be able to choose a folder containing (among others) images. These images should be listed in a table according to their posix path. It’s based on ben Waldie’s table example but with a lot of extentions.

	set theFolder to choose folder without invisibles
	tell application "Finder"
		set theFiles to every file of theFolder  <== problem 1
		set theTableViewContents to {}
		repeat with a from 1 to length of theFiles
			set theCurrentFile to item a of theFiles
			set theCurrentFileName to name of theCurrentFile  <== problem 2
			set end of theTableViewContents to {theCurrentFileName, theCurrentFile as string}
		end repeat
	end tell

  • problem 1:
    I’m trying to do: set theFiles to every file of theFolder whose file type is in {“JPEG”, “TIFF”}
    I can’t get this to work.

  • problem 2:
    the files displayed are in the form “Macintosh HD:Users:…” (etcetera), where I want them to be “/Macintosh HD/Users/…” (etcetera)

When working with the choose file option (with multiple selection) I have no problem getting the above to work, but I can’t get it working on an entire directory with choose folder.

Hi,

problem 1:
I suggest

set theFiles to every file of theFolder whose name extension is in {"JPG", "JPEG", "TIFF", "TIF"}

problem 2:

set end of theTableViewContents to {theCurrentFileName, POSIX path of theCurrentFile}

Note: the path will be displayed “/Users/.” A POSIX path never contains the name of the startup volume

That works fine.

This needs to be: set end of theTableViewContents to {theCurrentFileName, POSIX path of theCurrentFile as string}
or: set end of theTableViewContents to {theCurrentFileName, POSIX path of theCurrentFile as Unicode text}

Thanks for pointing me in the right direction. I positioned the posix path at the wrong point.

Yeah, I know. Just a too quick copy&paste.

Thanks (again) for your almost instantanious response.

Try removing the coercion and changing this earlier line:

set theFiles to (every file of theFolder whose name extension is in {"JPG", "JPEG", "TIFF", "TIF"}) as alias list

Thanks. That works fine.