W
wbeldman
I am trying to traverse the file system on a remote computer from a
Windows machine to report on specific extensions. Here is the source
code:
=====================================
#! C:\Perl\bin\perl.exe -w
####
# This program was generated by 'find2perl' and is slightly tweaked to
suit our needs (on Windows).
# usage is: findext.pl directory extension
# eg. findext.pl \\cluster\itshome doc
eval 'exec C:\Perl\bin\perl.exe -S $0 ${1+"$@"}' if 0; #
$running_under_some_shell
use strict;
use File::Find ();
# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.
# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find:rune;
sub wanted;
if ($#ARGV+1 != 2){
die "Proper usage:\n\t$0 directory ext\n\tdirectory=$ARGV[0] and
extension=$ARGV[1]\n";
}
if (!(-d $ARGV[0])){
die "$ARGV[0] is not a valid directory\n";
}
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, "$ARGV[0]");
exit;
sub wanted {
#Replace \\cluster.../folder/something.mp3 with \\cluster...\folder
\something.mp3
$name =~ s/\//\\/g;
if (/^.*\.$ARGV[1]\z/s){
print "$name\n";
}
}
=====================================
The program works great except when I run into a directory which is
too long. In windows explorer, I can't CD to a path like \\compname
\sharename\directory\{many subdirectories}\directory because I get:
"Can't access this folder Path too long". When I use the above program
it crashes at that point and I get:
=====================================
Can't opendir(\\compname\sharename\directory\{many subdirectories}
\directory): No such file or directory
at D:\Scripts\dev\Send Reports\MP3 Reports\findext.pl line 30
Can't cd to \\compname\sharename\directory\{many subdirectories}
\directory../.. at C:/Perl/lib/File/Find.pm line 896.
=====================================
My question is, how would I get around this problematic directory and
just let my program continue on to all the other directories in that
share?
Windows machine to report on specific extensions. Here is the source
code:
=====================================
#! C:\Perl\bin\perl.exe -w
####
# This program was generated by 'find2perl' and is slightly tweaked to
suit our needs (on Windows).
# usage is: findext.pl directory extension
# eg. findext.pl \\cluster\itshome doc
eval 'exec C:\Perl\bin\perl.exe -S $0 ${1+"$@"}' if 0; #
$running_under_some_shell
use strict;
use File::Find ();
# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.
# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find:rune;
sub wanted;
if ($#ARGV+1 != 2){
die "Proper usage:\n\t$0 directory ext\n\tdirectory=$ARGV[0] and
extension=$ARGV[1]\n";
}
if (!(-d $ARGV[0])){
die "$ARGV[0] is not a valid directory\n";
}
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, "$ARGV[0]");
exit;
sub wanted {
#Replace \\cluster.../folder/something.mp3 with \\cluster...\folder
\something.mp3
$name =~ s/\//\\/g;
if (/^.*\.$ARGV[1]\z/s){
print "$name\n";
}
}
=====================================
The program works great except when I run into a directory which is
too long. In windows explorer, I can't CD to a path like \\compname
\sharename\directory\{many subdirectories}\directory because I get:
"Can't access this folder Path too long". When I use the above program
it crashes at that point and I get:
=====================================
Can't opendir(\\compname\sharename\directory\{many subdirectories}
\directory): No such file or directory
at D:\Scripts\dev\Send Reports\MP3 Reports\findext.pl line 30
Can't cd to \\compname\sharename\directory\{many subdirectories}
\directory../.. at C:/Perl/lib/File/Find.pm line 896.
=====================================
My question is, how would I get around this problematic directory and
just let my program continue on to all the other directories in that
share?