--- Hans <hansfong@email-addr-hidden> wrote:
> Hello everyone,
>
> Maybe not entirely related to music, so forgive me for that. I have been
> busy with the following problem for sometime now and I can't seem to
> figure it out.
>
> I want to batch create symlinks in the main directory, of all the files
> in subdirectories. E.g.
>
> $ls
> dir1
> dir2
> dir3
> file1.mp3 -> .dir1/file1.mp3
> file2.mp3 -> .dir1/file2.mp3
> file3.mp3 -> .dir2/file3.mp3
> file4.mp3 -> .dir2/file4.mp3
> file5.mp3 -> .dir3/file5.mp3
> file6.mp3 -> .dir3/file6.mp3
>
> I tried various shell thingies like:
>
> for i in *.mp3; do ln -s --target-directory=../ $i $i; done
>
> in the subdir, or
>
> for i in ./dir1/*.mp3; do ln -s $i $i;done
>
> with various variations, but it seems impossible to do it this way. What
> is the right way to go about this? I know very little Python and some
> bash scripting. I want to figure the solution out myself, so any
> suggestions/hints related to Python/bash are more than welcome.
>
> Cheers,
>
> Hans
>
How about this?
for x in `find . -type f -name '*.mp3' -print`
do
b=`basename $x`
ln -s $x $b
done
Careful about the quotes, some are backquotes.
I didn't test it, it's just off the top of my head.
You might try it with "echo" before the ln command
just to see what it's going to do before you fire
it off for real.
-- steve
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Received on Sun Jul 9 04:15:07 2006
This archive was generated by hypermail 2.1.8 : Sun Jul 09 2006 - 04:15:07 EEST