2 Replies Latest reply: Mar 15, 2011 1:53 PM by Irvingmike
Irvingmike Level 1 Level 1 (0 points)
I am working on a script for my company that sets up a basic folder structure for each job that we get. I do not have a lot of scripting experience and the part I am stumbling on is, I have a folder on a smb server that I would like to create an alias to on a afp server. I struggled for a while to make folders on the smb drive, but finally was able to do that with some shell scripts.

Here is my script (short to address the current issue):

-- Default Values for testing (Comment out in final script)
set Client_Name to "Aaron Anderson"
set Job_Number to "123456"
set PjMNameLong to "Emily Walbridge"

--Mounting Drive
tell application "Finder"
mount volume "afp://prep1/Opus"
mount volume "smb://gbpnet/DOCUMENTS"
end try
end tell

--Variable setting
set Job_Info to Client_Name & " " & Job_Number
set Job_DUA to Job_Info & " DUA"
set Job_Dir to "Opus:1 Active Prepress:" & Job_Info
set PjMNameLong to "Emily Walbridge"
set PjMNameShort to "Emily W"
set JobLog_PjMName to " To " & PjMNameShort & "'s Prepress Shared folder"

--Making folder structure in the PjMs Prepress Shared folder
set ClientNameShell to findAndReplace(" ", "\ ", Client_Name)
set PjMNameShell to findAndReplace(" ", "\ ", PjMNameLong)
set PjMShareMain to "/Volumes/DOCUMENTS/Staff\ Folders/Project\ management/" & PjMNameShell
set PjMShareClient to PjMShareMain & "/" & ClientNameShell
set mkdir_var to "mkdir " & PjMShareClient
do shell script mkdir_var
end try
set mkdir_var to mkdir_var & "/" & Job_Number
do shell script mkdir_var

--Aliasing DUA folder back to job folder
tell application "Finder"
make new alias to PjMShareClient at folder Job_Dir
set name of alias file Job_DUA of folder Job_Info of folder "1 Active Prepress" of disk "Opus" to "zzz DUA"
end tell

on findAndReplace(To_Find, To_Replace, The_String)
set text item delimiters to To_Find
set Text_Items to text items of The_String
set text item delimiters to To_Replace
set The_String to Text_Items as string
end findAndReplace

When run I get the following error:

error "Finder got an error: Can’t make "/Volumes/DOCUMENTS/Staff\\
Folders/Project\\ management/Emily\\ Walbridge/Aaron\\ Anderson" into type
item." number -1700 from "/Volumes/DOCUMENTS/Staff\ Folders/Project\
management/Emily\ Walbridge/Aaron\ Anderson" to item

Anyone have any suggestions as to how to make it work?

Also I would like to put a check in early in the script to see if the folder already exists, if it does not exist then alert the user.I have been successful with this on a afp drive using the following script chunk:

if (exists folder Client_Name of folder "Webtrack_Images") is false then
display alert "Alert: Client Does Not Exist in Webtrack_Images Drive"
message "This client does not exsist in the Webtrack_Images drive. If
this is not a new client, please cancel the script and check the client
name you entered." buttons {"Cancel", "OK"} default button 1
end if

But this code always says the folder does not exist when trying to run it on a smb drive.

Thanks for your help.

Mac OS X (10.6.6)