Jump to content
Server Maintenance This Week. ×

Get file path


This topic is 5277 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi

I need to have a text field displaying a folder path and a simple button to open that folder in finder.

My problem is that I don't want to just type the path in the field. I need to be able to select the folder in finder. And then, of course, use the button to open it. I haven't use applescript before and I don't know where to start.

Any help?

Link to comment
Share on other sites

Ah, time does fly. Since writing that routine, I've become aware of a much faster way to convert AppleScript lists to return-separated text lists; repeat is kind of slow (with hundreds of files):(

set aFolder to (choose folder)



tell application "Finder"

	set theList to files of aFolder as alias list

	-- set theList to files of entire contents of aFolder as alias list

	set old_delims to AppleScript's text item delimiters

	set AppleScript's text item delimiters to return

	set theFiles to theList as text

	set AppleScript's text item delimiters to old_delims

	return theFiles

end tell

The commented out line, with "entire contents" can be used instead of the line above it, to get all the files recursively inside a folder, and folders within that folder, and on and on.

BTW, as of 10.6 Snow Leopard, it is now recommended to put "choose folder" outside of app tell blocks. Actually any command from the Standard Additions. Though one can safely ignore, for now anyway.

Link to comment
Share on other sites

This topic is 5277 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.