#!/usr/bin/perl -w #Do Not run as Root, this may cause dirs to be link and corrupt the; #file system; my $start; my @in; my @big; my @next; my $level; my $dir; my @files; my $file; my $z=0; my $target; print "\n\n ***********************************\n"; print "This script will create (symbolic) links recursively\n"; print "to all files in the specifiled directory and also create\n"; print "the links from the directory specified\n"; print " ***********************************\n\n"; print " Please enter the starting target directory\n"; print " (don't end with a slash)\n"; $start=; chomp $start; print " \nEnter the working dir where you would like\n"; print " the links to be placed?\n"; print " (don't end with a slash)\n"; $target=; chomp $target; @in = (glob("$start*/")); @big = (@in); do { @next = (@in); @in = (); foreach $level (@next) { @in = (@in, (glob("$level*/")))} @big = (@big, @in); @next = ();} while $in[0]; foreach $dir (@big) { @files = (@files, (glob("$dir*"))); } foreach $file (@files) { $z=$z+1; $link = "$target"."/"."$z"; print "$z \-\- $file\n"; # to creat a symbolic link change link to symlink; link("$file","$link") || warn "can't link to file $file\n"; }