]> arthur.barton.de Git - netatalk.git/blob - contrib/shell_utils/netatalkshorternamelinks.pl
small adaptations for CVS tree
[netatalk.git] / contrib / shell_utils / netatalkshorternamelinks.pl
1 #! /usr/bin/perl 
2 #
3 # $Id: netatalkshorternamelinks.pl,v 1.2 2001-05-07 14:16:47 rufustfirefly Exp $
4
5 # (c) 2000 Christian Wolff, scarabaeus@scarabaeus.org
6 # quick hack to create symbolic links for files with names over 31 chars long 
7
8
9 $searchpath='/data/mp3/';
10 $destpath='/data/mac_mp3/';
11
12 # only if you dare!
13 `rm -rf ${destpath}*`;
14 foreach $f (`find $searchpath -name '*.mp3'`) {
15         chomp $f;
16         $f=~s/^$searchpath//;
17         if ($f=~/^(.*)\/(.*)$/) {
18                 ($path,$file)=($1,$2);
19         } else {
20                 ($path,$file)=('',$f);
21                 }
22         $shortpath='';
23         for $splitpath (split /\//,$path) {
24                 if (length $splitpath > 31) {
25                         # keep the last 2 chars of the directory name
26                         $splitpath=substr($splitpath,0,29).substr($splitpath,-2,2);
27                         }
28                 $shortpath.="${splitpath}/";
29                 mkdir $destpath.$shortpath,0755;
30         }
31         $shortfile=$file;
32         if (length $file > 31) {
33                 # keep the extension of 4 chars
34                 $shortfile=substr($file,0,27).substr($file,-4,4);
35         }
36         `ln -sf ${searchpath}${f} ${destpath}${shortpath}${shortfile}`;
37 }
38