How do I print all .pdf files names to an output file with command line?

前端 未结 5 1265
逝去的感伤
逝去的感伤 2021-02-04 08:53

This seems easy in Linux, but I\'m trying to print the names of *.pdf files within a directory and its subdirectories to an output file. I have Perl installed on my

5条回答
  •  甜味超标
    2021-02-04 09:40

    File::Find::Rule is often nicer to use than File::Find.

    use File::Find::Rule;
    
    my $rule = File::Find::Rule->file()->name('*.pdf')->start('C:/Path/');
    while (defined (my $pdf = $rule->match)) {
        print "$pdf\n";
    }
    

    or simply

    use File::Find::Rule;
    
    print "$_\n" for File::Find::Rule->file()->name('*.pdf')->in('C:/Path/');
    

提交回复
热议问题