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

Poeben

macrumors 6502
Original poster
Jul 29, 2004
346
0
I've been trying to get a script working that will do the following things:

1. Create a new folder everyday, on startup, with that day's date as the folder name. (The easy part)
2. Create an alias (or rather update the existing alias) on the desktop that points to this newly created folder. (this is what I can't figure out)
3. Only create the folder once in a day (seems to work ok)

So far I am able to create the folders ok, and even with multiple reboots it still seems to work, as if the folder exists I won't create it again. The problem is I can't get the alias to update/replace. It does, however, seem to create one in the folder that the original alias points to. Can anyone help? Here's where my script is currently (a bit of a mess as i've been messing with it for a while):

Code:
function alias {
	readlink -n ~/Desktop/_AUDIO_FILES_DAILY_
}
	
target=/Volumes/MEDIA/Audio\ Files/$(date +%y%m%d)

audiolink=alias

if [ "$audiolink" != "$target" ]

	then
		mkdir /Volumes/MEDIA/Audio\ Files/$(date +%Y%m%d)
		ln -sf /Volumes/MEDIA/Audio\ Files/$(date +%Y%m%d) ~/Desktop/_AUDIO_FILES_DAILY_
	else
		echo All Good

fi

Thanks
 

iSee

macrumors 68040
Oct 25, 2004
3,540
272
Look up the n option for ln. I think you want that.

I think the problem is that it is treating ~/Desktop/_AUDIO_FILES_DAILY_ as the destination directory for creating a new link.
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
You might need / at the end of the ln command,

ln -sf /Volumes/MEDIA/Audio\ Files/$(date +%Y%m%d) ~/Desktop/_AUDIO_FILES_DAILY_/


Maybe ... didn't try it personally
 

Poeben

macrumors 6502
Original poster
Jul 29, 2004
346
0
Thanks for the replies. I think I may have misunderstood the difference between source and target. I did try the -n flag, but I was getting an error but that could have been a result of the swapped source/target.

There's really no reason why I couldn't delete the link other than the hope that if I were to update it instead perhaps it would remain in the same place on the desktop.

I'll have to wait until monday to try it out, but thanks for the help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.