Jump to content

Recommended Posts

Posted

I've created a script that it supposed to map each user on the network an individual drive that is stored on a windows media server.

 

It does the following;

 

Mount share

 

Create folder on share based on username

 

Map that folder (ie share/username)

 

Unmount share on higher level so user is left with share/username only.

 

Only problem is that my script fails if the folder exists already.

 

So i put an "if not exists" in but it appears to be doing nothing as when i run the script i get back "cannot create folder as it already exisits"..

 

Can anyone point me in the right direction here? I've attached the script below.

 

Thanks in advance!

 

Martin

 

 

 

 

set username to (do shell script "whoami")

set Media to " Media Files"

mount volume "smb://172.22.8.23/macmedia$"

tell application "Finder"

if not (exists ("smb://172.22.8.23/macmedia$/" & username as text) & Media as text) then
	
	make new folder at "macmedia$" with properties {name:(username as text) & Media as text}
	
end if

end tell


tell application "Finder"

set mnt to ("smb://172.22.8.23/macmedia$/" & username as text) & Media as text

try
	mount volume mnt
	
end try

eject "macmedia$"

end tell

Posted

Hi

 

It's probably simply a typo but you have an extra space between the first double quotes and the word Media. Apart from that your question might get more attention if you posted here:

 

https://discussions.apple.com/community/mac_os/mac_os_x_technologies?view=discussions#/?tagSet=1044

 

Apple maintain other dedicated forums in addition to the AppleScript one. This one is for Unix:

 

https://discussions.apple.com/community/mac_os/mac_os_x_technologies?view=discussions#/?tagSet=1048

 

HTH?

 

Antonio Rocco (ACSA)

Posted

Hi Antonio,

 

The space before media is just to split the text label for the folder so it's called username*space*Media Files. There was probably an easier way of doing this but I'm relativey new to applescript and that part of the script was working okay.

 

Cheers for the link, i'll post up on the apple forum.

 

I think my question can be simplified to "Using an "if not exists" command with a folder on an SMB share" so i'll post it as that.

 

Thanks again,

 

Martin

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...