FInding the Path of a Folder

Hi All,
Can anyone pls tell me how to find the path of a folder in applescript.I want the path of a folder by passing just the nameof the folder.Like i pass “IDrive” and i get the path to this folder.Pls its a bit urgent.

Thanks In Advance

If a drag and drop app will work, this may help

I don’t remember who the Author of the above script is, sorry about that. Here’s a simpler form of a drag and drop path finder.

You could replace the ‘display dialog thePath’ with ‘set the clipboard to thePath’.

In AppleScript you can only guess the path of some special folders, such as the applications folder (see “path to” command from Standard Additions).
For the rest of folder, you must find it yourself, using, eg, shell’s “find” command:

do shell script "find ~/desktop -name 'lDrive' -type d"

Which will return a posix path for any folder called “lDrive” in your desktop-user-folder and subfolders.

Hi ,
Thank u very much for the reply.I have got some doubts in the script u have posted.I want to find the path of a folder called “IDrive”.It tried using
Tell Application “Finder”
What code must come here to get the path of folder “IDrive”.
End Tell

Suresh, where is the folder named “IDrive” located?

The folder can be located anywhere.My requirement is the user downloads a .sit file from the web.The sit file has got a folder called “IDrive”.The user may download it anywhere in his machine.To run my program i have got to get the path of “IDrive” and after getting this path i have got to execute my program.


I need more info, is the file that’s downloaded from the internet a file you have control over? Or is a file from some one elses web site? If you have control, you could add an installer to the .sit package the would do what ever you need to do to the files. I used this script to install files from a downloaded internet file and it worked for my situation.

You’ll have to change the do shell script to suit your needs, but maybe that can get you started. If you have no control over the file that is downloaded, then it’s just a guessing game as to where the file may be located on the machines hard drive.

Hi Suresh :slight_smile:
I really do not understand… your program is in the “IDrive” folder anywhere in the user machine? … thats right ?
In this case, perhaps this small code could be enough :

set MyPath to (path to me) as alias
tell application "Finder" to set MyFolder to (folder of MyPath) as alias

Otherwise, please specify a little more your question. Thanks :slight_smile:

:slight_smile: SOrry All if the way i asked the question is confusing.To make it simple i have got a folder called “IDrive” in my mac machine.I want to get the path of this folder from my applescript applicaton how can i get it .


I think jj’s advice about using the shell find command is probably what you need.

Yup, JJ had it. To narrow it down a bit you could use…

do shell script "find $HOME -name 'IDrive' -type d"
set the clipboard to result

It still may take a while, it took 13 seconds to find it tucked away on my drive. But it beats searching from the root dir.

HI All,
Thanks u very much for the help .I am able to get the folder path using the "do shell script find ". But i am here again for more help and advice from you people. i use the following two shell scripts

  1. do shell script “cd /users/apple/desktop/idrive”
  2. do shell script " sudo stunnel"

As u know one shell script doesnt has any refernce to the second one.Hence i have got to combine the above both into one script command.How do i do it.

i want something like
do shell script"cd /users/apple/desktop/idrive; sudo stunnel" with administrator this possible .if not pls tell me how to combine both scripts into one.

if combining both is not possible how can i first make idrive the current directory and then use the command “sudo stunnel” since executing stunnel requires the current directory to be the directory in which stunnel is present.


“cd /users/apple/desktop/idrive; sudo stunnel” is ok.
“sudo /users/apple/desktop/idrive/stunnel” is ok.

If you’re using with administrator privileges, you shouldn’t need sudo.

Using a double ampersand instead of a semicolon, as in cd /users/apple/desktop/idrive && sudo stunnel, is slightly better because if the cd should fail for any reason, the second command will not be invoked. In this regard, it operates the same as the other form which jj cited. (Of course if you’re using administrator privileges, the sudo is superfluous in either form.)

Also note that the difference between the command above (using either the semicolon or the double ampersand version) and the other form jj cited, sudo /users/apple/desktop/idrive/stunnel, is that in the latter, stunnel is invoked from the root level directory, whereas the former is invoked from /users/apple/desktop/idrive/. That might be a reason to choose one form over the other. If not, the sudo /users/apple/desktop/idrive/stunnel form is simpler and more concise, and therefore somewhat more preferable in my opinion. Clearly, YMMV depending upon your application.