~ubuntu-branches/debian/lenny/netatalk/lenny

« back to all changes in this revision

Viewing changes to contrib/shell_utils/netatalkshorternamelinks.pl.in

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2005-10-07 13:46:11 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20051007134611-r07qa2g67xwkp2if
Tags: 2.0.3-1ubuntu1
* debian/netatalk.init
  - run cnid_metad if CNID_METAD_RUN=yes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!@PERL@
2
 
#
3
 
# $Id: netatalkshorternamelinks.pl.in,v 1.1 2002/01/17 05:59:25 srittau 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