Tuesday, January 6, 2009

Symbolic Links

Info from following URLs:

    Recently I sent an email to the Audacity Team to see if Audacity's temp directory could be set using commandline parameters. Below is an extract of my email and Richard Ash's reply.

> I'm using the Asus Eee PC and using the Debian
> distribution of Audacity for the Xandros OS. I set my
> temp directory to the SD Card in the card slot, but in
> Linux, there is no drive name - it goes by the name of
> the card, so if I change cards, Audacity can't find
> the temp directory anymore.
> Example:
> My card is labelled Kingston.
> When I go into /home/user/MMC-SD, I see the folder
> Kingston
> My card is labelled Toshiba.
> When I go into /home/user/MMC-SD, I see the folder
> Toshiba.
---/* Reply */
Why not create a symlink from a convenient directory that doesn't change
to the currently inserted flash card. So for example with each different
card inserted create a symlink from /home/user/.audacity_temp
to /home/user/MMC-SD//.audacity_temp as required. You can then
set audacity to always use /home/user/.audacity_temp as the temporary
directory, and the data will end up on whichever card is in use.

    Kudos to Richard for such an ingenious reply! As mentioned before, I'm not the only one using my Eee PC for recording, so there is the possibility that the person handling my Eee PC might just insert his own SD Card, in which case the problem above would surface. I edited the bash script for launching Audacity in my Easy Mode GUI as shown below (see earlier posts on KDialog and Easy Mode GUI on how to set the shortcut):

#create symbolic link from SD Card to /home/user.
#create .audacity_temp/ in SD Card if it does not exist.

#Get name of SD Card in card slot
for file in $DIRECTORY/*

#check if .audacity_temp/ exists in SD Card
if !(test -d $firstdir)
echo making
sudo mkdir $firstdir

#create symbolic link to /home/user/.audacity_temp.
#Must remove old link 1st
rm /home/user/.audacity_temp
ln -s $firstdir /home/user/.audacity_temp

title="Audio Recording Checklist"
msg1="1) Is the power plugged in and SWITCHED ON?"
msg2="2) Is the mic volume around 1/4 level? (volume icon at bottom right of screen)"
msg3="3) When recording is done, go to File, 'Export as MP3'."
kdialog --msgbox "$myMsg"

exit 0

    The creating of the symbolic link (or symlink or soft link) is done using the command "ln". Now I have a symlink in /home/user called .audacity_temp which shows the link when my mouse cursor hovers over it in File Manager (go to View -> Show Hidden Files to see it)

(^ v ^)