3 # acleandir [-rvnid] dir
5 # removes orphan AppleDouble files
7 # gerry.tomlinson@ncl.ac.uk 2/3/98
9 # note - don't follow symbolic links to directories in recursive option
13 ~ $1/* $1/'*' && return 0
18 ~ $ropt 1 && for (i in $1/*) {
19 [ -d $i -a ! '(' $testsym $i ')' ] && doit $i
28 # first handle the .AppleDesktop dir
30 if (~ $aopt 1 && [ -d $ADT ] ) {
32 echo -n remove $ADT '?'
33 ~ `{line} [yY] && rm -r $ADT
36 echo $ADT to be removed
42 # now look at the .AppleDouble dir
44 emptydir $AD || for (i in $AD/*) {
45 if (~ $aopt 1 || ! afile $i >/dev/null >[2=1] ) {
48 ! ~ $size(1) 589 && sizemess = 'size='^$size(1)
51 echo -n remove '`'$i''''^$sizemess^' ? '
52 ~ `{line} [yY] && rm $i
55 echo '`'$i''''^' to be removed '^$sizemess
56 } else rm $i && ~ $vopt 1 && echo $i removed
61 if ( ~ $dopt 1 && emptydir $AD ) {
63 rmdir $AD >/dev/null >[2=1] && ~ $vopt 1 && echo empty directory $AD removed
75 # first cope with different test for symlink options
78 [ - L . ] >[2] /dev/null
79 ~ $status 1 || testsym = -h
81 ~$#* 0 || * =`{getopt darnviR $*}
96 shift; aopt = 1; dopt = 1;
102 ~ $#* 0 && {echo usage: acleandir [-rnvia] dir; exit 1}
104 [ -d $1 ] || {echo >[1=2] acleandir: $1 not a directory; exit 2}