#!/usr/bin/perl -w # ################################################################### # # Name: removeDotUnderscore.pl # Version: 1.2 # Author: Pete # Author-Email: pete@rasterweb.net # Date Created: 08.08.2002 # Date Modified: 03.05.2003 # Purpose: cleans up those pesky ._ files that Mac OS X # likes to make on SMB shares... # it just ain't unix-like! # # this script runs interactively, as to prevent # the rare case where someone actually wants a # file starting with ._ # # # This is free software, you may use it and distribute it under the # same terms as Perl itself. # #################################################################### use File::Find; $File::Find::dont_use_nlink = 1; # fix for Windows shares my $dir = shift (@ARGV); my $rmct = 0; if ($dir eq "") { print "\n usage: perl removeDotUnderscore.pl /path/to/some/directory\n\n"; exit; } my @dirs = ($dir); find(\&deletefiles, @dirs); print "\n$rmct files were removed.\n\n"; ################### # subs below here # #################################################################### #################################################################### sub deletefiles { my $file = $File::Find::name; my $dir = $File::Find::dir; if ($_ =~ /^\._/) { print "Remove: $file (y/n) :"; $res = ; chomp $res; if ($res eq 'y') { unlink $file; $rmct++; } } } # end sub deletefiles __END__