HELP: File path to mounted server

Hi guys, I am a low end script user. I get a lot done with scripting, but I am sure my methods are less than ideal. That said, I need to modify some existing scripts that call files from the Finder. These scripts work fine on multiple standalone desktops but we are now moving the files to an afp file server.

The problem:
I need to change the file paths so that they can find the files on the server volume (which is already mounted). What is the proper syntax for such a path structure. Currently I am using the base the from the Users folder and then appending the needed path details for the specific file – so it would seem to be simple enough to modify the portion of my script that designates the User folder to designating the server folder.

I have tried several path structures with no success (it says that it “can’t get file” at that address):

 afp://serverIPaddress/pathtofolder
 afp://serverIPaddress/volumename/pathtofolder
 volumename/pathtofolder

All the web searches I find seem to reference mounting the server, which I can do with no problem - I just can’t get the path structure correct. Any help would be greatly appreciated.

The user’s computers and the server are Mac OSX machines using either 10.5 or 10.6 connecting via afp.

Roger

If your volume is already mounted, then you should be able to access it with:

/Volumes/VolumeName/path/to/your/file

For the direct afp connection, you can try:

afp://username@serverIPaddress/pathtofolder - this will prompt for the user’s password

or

afp://username:password@serverIPaddress/pathtofolder

kwolf22 – many, many, many thanks! It always amazes me how being off by one character can bring everything to a grinding halt. Thanks again.

Roger

kwo;f22

I am having a problem with the solution you provided and would like your advice. When I tested your script, I made a short script that would open a text file o the main level of the mounted volume. It worked perfectly. Now when I try to incorporate your advice into one of my actual scripts, I get errors (it says it can’t get the folder “ScriptReference”).

My Old code that worked fine when files were on the local drive:

–set variables
set ZbasePath to (path to home folder) as string
set Ztarget to “Storage:Scripts:ScriptReference”

set Ztargfolder to ZbasePath & Ztarget

set Z12stocksfile to ZbasePath & “Storage:Database:DB_Files:STCK_12Daily_DB.fp7”
set Zmarketfile to ZbasePath & “Storage:Database:DB_Files:STCK_MktDaily_DB.fp7”

–get filename of first file in folder
tell application “Finder”
set Zorderslist to {}
set currentFile to first file of folder Ztargfolder
set currentFileName to (the name of currentFile)
end tell

All files we will be accessing used to be held in a master folder called “Storage”. The mounted drive is now called “Storage” and there is no master folder containing the items on that drive. So my thought was to simply change the first variable (Zbasepath) to be “/volumes/”. This in theory would build the perfect path based on your advice ” and in fact it worked perfectly on my test script:

set v1 to “/Volumes/”
set v2 to “Storage/test.txt”
set v3 to v1 & v2

tell application “TextEdit”
activate
open v3
end tell

the code that I have that is failing is:

–set variables
set ZbasePath to “/Volumes/”
set Ztarget to “Storage:Scripts:ScriptReference”

set Ztargfolder to ZbasePath & Ztarget

set Z12stocksfile to ZbasePath & “Storage:Database:DB_Files:STCK_12Daily_DB.fp7”
set Zmarketfile to ZbasePath & “Storage:Database:DB_Files:STCK_MktDaily_DB.fp7”

–get filename of first file in folder
tell application “Finder”
set Zorderslist to {}
set currentFile to first file of folder Ztargfolder
set currentFileName to (the name of currentFile)
end tell

any suggestions as to why it works on the simple test and fails in my bigger script?

thanks
Roger

Hi,

in the first example you’re using only HFS paths (colon separated), which is the primary path specifier of AppleScript.
POSIX paths (slash separated) or mixed forms like in the second example don’t work.

As HFS paths start always with a disk name, this is sufficient


set Ztargfolder to "Storage:Scripts:ScriptReference:"

StefanK

oops, I meant to change that. Thanks for pointing it out. It seems to be getting further in the script, but now it is erroring out on the line noted below:

--set variables
set ZbasePath to  ":Volumes:"
set Ztarget to "Storage:Scripts:ScriptReference"

set Ztargfolder to ZbasePath & Ztarget

set Z12stocksfile to ZbasePath & "Storage:Database:DB_Files:STCK_12Daily_DB.fp7"
set Zmarketfile to ZbasePath & "Storage:Database:DB_Files:STCK_MktDaily_DB.fp7"

--get filename of first file in folder
tell application "Finder"
    set Zorderslist to {}
--ERRORS ON NEXT LINE
    set currentFile to first file of folder Ztargfolder
    set currentFileName to (the name of currentFile)
end tell

it is saying: Finder got an error: Can’t get folder “:Volumes:Storage:Scripts:ScriptReference”

Again, this all worked fine before I switched that first line of code to handle the Volumes. Frustrating.

Thanks
Roger

as mentioned above, HFS paths start always with a disk name, never with the folder Volumes

these two forms represent the same path

POSIX path

/Volumes/Storage/

HFS path

Storage:

Thanks Stefan, I would have sworn I tried that HFS format 1 minutes earlier, but it would not work - but it does now, so I must have had a typo somewhere.

Thanks for the help.