Is there a better way create a folder?

Hi

Is there a better way to do this (see code below), it seems a bit long. All I want is to choose/create an output folder than create an “images” folder inside it, I need unixy paths cos I whack it with a shell script later…


choose folder with prompt "Select album folder:"
set my_folder to result
set output_folder to POSIX path of my_folder -- want a unix type path
tell application "Finder"
    make new folder at my_folder with properties {name:"images"}
end tell
set image_folder to result as string
set image_folder to POSIX path of image_folder

I’d probably go with something like this.

set my_folder to (choose folder with prompt "Select album folder:")
set output_folder to quoted form of POSIX path of my_folder -- want a unix type path 

tell application "Finder"
	try -- in case a folder named "images" already exists in my_folder
		set image_folder to (make new folder at my_folder with properties {name:"images"}) as text
	on error e
		display dialog e
		set image_folder to quoted form of POSIX path of ((my_folder as text) & "images")
		return
	end try
end tell

set image_folder to quoted form of POSIX path of image_folder

Using “quoted form of POSIX path” escapes spaces in file/folder names, making them more shell friendly.

– Rob

thanks for your help rob, didn’t know about “quoted form of POSIX path”

And ‘quoted form’, technically a property of strings, isn’t just for paths, although that’s a common and useful employment for it–you can use it to quote any arguments to a shell command which might have characters the shell considers special.