Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Beeblebrox42

macrumors newbie
Original poster
Mar 16, 2008
19
0
Hi there,

I know very little about AppleScript but I need to make a script to create folders on a server.

Here is what I am looking to occur:

- Check a sharepoint for a folder named %username% (where username is a 5 digit number)
- If the folder is there, mount it
- If the folder isn't there, create it, call it %username%.
- mount the newly created folder

I would be really grateful of any help with this.
 
Hi there,

I know very little about AppleScript but I need to make a script to create folders on a server.

Here is what I am looking to occur:

- Check a sharepoint for a folder named %username% (where username is a 5 digit number)
- If the folder is there, mount it
- If the folder isn't there, create it, call it %username%.
- mount the newly created folder

I would be really grateful of any help with this.

Why Applescript ? Sounds like a 3 minute job for bash.

Code:
#!/bin/bash

SHARE="sharepoint"

usage()
{
        echo "Usage: $0 <username>"
        echo "Synopsis : checks $SHARE for a directory named <username>, creates it if it doesn't exist"

}

if [ $# -eq 1 ]; then
        USERNAME=$1
        EXISTS=`ls $SHARE | grep $USERNAME | wc -l`
        if [ $EXISTS -eq 0 ]; then
                echo "Creating folder $USERNAME"
                mkdir $SHARE/$USERNAME
        fi

        echo "Here we would mount the folder using good old Unix commands"
else
        usage
fi

Code:
$ sh test.sh
Usage: test.sh <username>
Synopsis : checks sharepoint for a directory named <username>, creates it if it doesn't exist
$ ls sharepoint/
12345  32415  54321  98765
$ sh test.sh 98765
Here we would mount the folder using good old Unix commands
$ sh test.sh 56789
Creating folder 56789
Here we would mount the folder using good old Unix commands
$

License to above code : Use it and you owe me 50000$ dollars as a consulting fee. This offer does not extend any warranties or garanties that the above will not awfully break any of your production servers or clients and I am fully discharged of any damages that might result in proper or misuse of this code. :D
 
thank you so much for your help, but I really have no clue how to impliment those items of code.

So far I have an Applescript that checks for a folder on a mounted volume, I am just looking for the code to create a folder in the event the folder is not there, then I would like a finder window to open with that folder!

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.