~ubuntu-branches/ubuntu/precise/netatalk/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Rittau
  • Date: 2004-01-19 12:43:49 UTC
  • Revision ID: james.westby@ubuntu.com-20040119124349-es563jbp0hk0ae51
Tags: upstream-1.6.4
ImportĀ upstreamĀ versionĀ 1.6.4

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