in reply to Re: How do I write NT perl script to search mult. dirs and output to a file?
in thread How do I write NT perl script to search mult. dirs and output to a file?

Thank you for responding. I'm continuing my learning by reading PERL books and sites like this one. Here is my attempt at accomplishing my mult-directory search of my C: drive for MP3 files. I first tried to do a simple array, which is commented out at the bottom of the script, but found that I couldn't get into sub-directories. I would like to output my search into the text file for review, then if I decide to go ahead and delete, I can un-comment my UNLINK statement. Any help would be appreciated....

I keep getting the following SYNTAX error: Can't locate File/Recurse.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/li b .) at C:\Rob\JHMCIS Scripts\MP3_Deletion.pl line 1. BEGIN failed--compilation aborted at C:\Rob\JHMCIS Scripts\MP3_Deletion.pl line 1.

*************************************
Here's my attempt:

open (MP3, ">c:\\perltest\\mp3log.txt"); recurse(\&Locate_MP3, "c:\\ "); close (MP3); sub Locate_MP3 # Recurses directory structure, #locates matching files, and deletes them(print to log #first, unlink +later after review). { if ( -f $_ ) { if ( $_ =~ /\.mp3$/i ) { # unlink ("$_") } } } print MP3 “$_ matches deletion criteria.\n”; # This was my first attempt at an array to do the same # thing. Only problem....only works on current directory. #open (MP3, ">c:\\perltest\\mp3test.txt"); #$timenow = time; #@mp3list = <c:\\perltest\\*.mp3>; #print MP3 "@mp3list\n"; #close (MP3);

Thanks,
Seeker of Perl Wisdom

  • Comment on Re: Re: How do I write NT perl script to search mult. dirs and output to a file?
  • Download Code