That is a good one! I have a feeling I'm going to use this one a lot,
because it makes sense. Thanks! --Hans
Phil Mendelsohn wrote:
Date: Sat, 08 Jul 2006 22:15:23 +0200
From: Hans <hansfong@xxxxxxxxx>
Subject: batch creation of symlinks
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
You might find this useful. (cp -s rocks!)
cd $TARGETDIR
(any loop stuff)
cp -s $FROMDIR *.mp3 ./
Cheers,
Phil