Click here to get back home

script to find the files with very long names

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
script to find the files with very long names pui ming Wong 06-12-2006
Posted by Jürgen Exner on May 19, 2008, 7:56 pm
Please log in for more thread options
dkcombs@panix.com (David Combs) wrote:
>>On 6/12/2006 2:34 AM, pui ming Wong wrote:
>>> My objective is to go down the current directory
>>> and have the system tells me which files have their names
>>> longer than say 26 characters
>>>
>>> i think mixing the unix find command
>>> with some other commands might do it.
>>> But a perl script might do it more tidily and faster ?
>>
>>find . -name "??????????????????????????*"

Ouch!

Ok, here's a fish:

use strict; use warnings;
use File::Find;
sub wanted{print "$_\n" if length>26;}
find(\&wanted, '.');

jue

Posted by Ilya Zakharevich on May 20, 2008, 1:21 pm
Please log in for more thread options
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Jürgen Exner
> use strict; use warnings;
> use File::Find;
> sub wanted{print "$_\n" if length>26;}
> find(\&wanted, '.');

Wrong. You do not want to use $_ there (or use 'nochdir'). Better, use

pfind . "length > 26"

Hope this helps,
Ilya

Posted by Jürgen Exner on May 20, 2008, 6:34 pm
Please log in for more thread options
>[A complimentary Cc of this posting was NOT [per weedlist] sent to
>Jürgen Exner
>> use strict; use warnings;
>> use File::Find;
>> sub wanted{print "$_\n" if length>26;}
>> find(\&wanted, '.');
>
>Wrong. You do not want to use $_ there (or use 'nochdir').

Why? The docs say
         "$_" [contains] the current filename
As far as I can tell that's exactly what the OP asked for: filenames
longer than 26 characters.

>Better, use
> pfind . "length > 26"

C:\tmp>perldoc -f pfind
No documentation for perl function `pfind' found

jue

Posted by Ilya Zakharevich on May 21, 2008, 4:12 am
Please log in for more thread options
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Jürgen Exner
> >[A complimentary Cc of this posting was NOT [per weedlist] sent to
> >Jürgen Exner
> >> use strict; use warnings;
> >> use File::Find;
> >> sub wanted{print "$_\n" if length>26;}
> >> find(\&wanted, '.');
> >
> >Wrong. You do not want to use $_ there (or use 'nochdir').
>
> Why? The docs say
>          "$_" [contains] the current filename
> As far as I can tell that's exactly what the OP asked for: filenames
> longer than 26 characters.

Try it. It is not good to give to print() - it will be no longer
"current enough", since current directory is "wrong".

> >Better, use
> > pfind . "length > 26"
>
> C:\tmp>perldoc -f pfind
> No documentation for perl function `pfind' found

use it anyway. ;-)

Hope this helps,
Ilya

Posted by Jürgen Exner on May 21, 2008, 8:27 am
Please log in for more thread options
>[A complimentary Cc of this posting was NOT [per weedlist] sent to
>Jürgen Exner
>> >[A complimentary Cc of this posting was NOT [per weedlist] sent to
>> >Jürgen Exner
>> >> use strict; use warnings;
>> >> use File::Find;
>> >> sub wanted{print "$_\n" if length>26;}
>> >> find(\&wanted, '.');
>> >
>> >Wrong. You do not want to use $_ there (or use 'nochdir').
>>
>> Why? The docs say
>>          "$_" [contains] the current filename
>> As far as I can tell that's exactly what the OP asked for: filenames
>> longer than 26 characters.
>
>Try it.

I did.

>It is not good to give to print() -

print() has no problems with that value. It prints the filename just
fine.

> it will be no longer
>"current enough", since current directory is "wrong".

I have no idea what you are trying to say.

>> >Better, use
>> > pfind . "length > 26"
>>
>> C:\tmp>perldoc -f pfind
>> No documentation for perl function `pfind' found
>
>use it anyway. ;-)

Bareword "pfind" not allowed while "strict subs" in use at c:\tmp\t.pl
line 3.
Execution of c:\tmp\t.pl aborted due to compilation errors.

>Hope this helps,

Sorry, it didn't.

jue

Similar ThreadsPosted
any script to find renamed wmf files? January 2, 2006, 12:06 pm
Script to find largest files November 1, 2007, 10:15 am
Rename files using directory names November 15, 2007, 8:33 am
rename not working on files with accents in names April 24, 2005, 12:04 am
How long is too long for cgi script? April 22, 2005, 12:07 pm
File::Find dies on directory paths which are too long March 13, 2007, 2:53 pm
How to find all the strings in a long that are at most of n different characters of a test string? November 19, 2008, 6:34 pm
Perl Script to change IPs to DNS Names November 16, 2006, 10:56 am
File slurp takes a long time on some files November 22, 2004, 6:43 pm
creating variable names within a perl script July 16, 2006, 3:14 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap