folder selection

Hi all,

how can I select a specific folder without “choose” and prompt window?

And the other thing I cannot find is how to rename files and only deleting the spaces. Trim won’t do because spaces can be anywhere in the filename.

Thanks for help.


Not sure exactly what you’re looking for in the first question, but this addresses the second:

set x to "   abc   def   "
set {saveDelims, text item delimiters} to {text item delimiters, " "}
set y to (text items of x)
set text item delimiters to ""
set z to y as text
set text item delimiters to saveDelims
--> "abcdef"

Hope that helps…

  • Dan

Hi Dan,
I will try to include your hint into my script.
Should work.

My first question is because I don’t want users to choose a folder. I want to use a folder action script that always uses the same folder to work. But in my script the window of the folder opens and I have to confirm that the chosen folder is to use for the script.


Hi Sabine -

If you’ll be using the same folder all the time, you can just hard-code it, i.e., where you would normally say

set fldr to choose folder with prompt "Choose folder:"

and “choose folder” returns an alias to, say, “Path:to:chosen:folder:”, you can just say

set fldr to alias "Path:to:chosen:folder:"

If you want to refer to the folder to which a folder action is attached (say for the “adding folder items to” handler) then your handler definition is something like

on adding folder items to fldr

you can refer to the folder of interest as “fldr” in an alias context and “fldr as text” in a text context.

I hope I’m understanding you correctly - apologies if not :slight_smile:

  • Dan