Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Operating System (http://www.mac-forums.com/forums/os-x-operating-system/)
-   -   Help making shell script for basic command (http://www.mac-forums.com/forums/os-x-operating-system/285424-help-making-shell-script-basic-command.html)

ericconn 09-26-2012 12:00 PM

Help making shell script for basic command
 
I need to make a shell script for a command to create aliases for 500 folders in 500 parent directories. I've found one page that was useful (http://www.alvinpoh.com/how-to-make-...al-in-mac-osx/), however I need to put the aliases on several computers, and once the aliases made with that script are off my computer, the aliases are "dead," due to rights permissions, I assume.

The command works when I copy and paste the commands one by one into Terminal, but I'd rather not do that.

Example of folder structure
server/
.......people/
.............person1/
.............person2/ etc.

Example of command being used
ln -s "/Volumes/server/people/person1" /shortcuts/

Thanks for any help.

Raz0rEdge 09-26-2012 04:43 PM

On Linux (that's what I have access to right now) something like this would work
Code:

for dir in `find /Volumes -mindepth 3`; do
    ln -s "$dir " /shortcuts/
done

The mindepth here ensures that you get the "server/people/personX" level. Without that, you end up getting "server" and "server/people" as well which you probably don't want.

If mindepth is supported by OS X's "find", then this script should work..

ericconn 09-26-2012 05:08 PM

Thanks, I see what you're getting at there, but that line of code didn't work. Here's a site with how OS X uses mindepth. Any suggestions how to change it to work? Thanks.

ericconn 09-26-2012 05:08 PM

sorry, link mentioned above: http://codesnippets.joyent.com/user/jvs/tag/prune


All times are GMT -4. The time now is 10:31 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.