User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Flatten directory structure with symbolic links Page [1]  
BIGcementpon
Status Name
11319 Posts
user info
edit post

I need some help writing a shell script that will recursively find all files in a nice, organized directory structure, and then create flattened symbolic links to all of those files in another directory. By flattened, I mean that I don't want the symlinks to be structured - they all get dumped in one directory.

I'm assuming some use of find or ls will be needed here, but I'm just not sure of the exact combination and Google hasn't been very helpful here.

5/17/2013 1:32:27 PM

llama
All American
841 Posts
user info
edit post

#!/bin/bash 

for i in `find $1/*`;
do
echo $i;
filename=$(/usr/bin/basename "$i")
ln -s "$i" "$filename";
done


but you'll need to find a way to handle spaces in filenames, assuming this is for a music collection or something similar.

5/17/2013 5:33:07 PM

 Message Boards » Tech Talk » Flatten directory structure with symbolic links Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.