Questions tagged [file-find]

41 questions
15
votes
1 answer

perl script to recursively list all filename in directory

I have written following perl script but problem is its always going in else part and reporting not a file. I do have files in the directory which I am giving in input. What am I doing wrong here? My requirement is to recursively visit every file in…
TopCoder
  • 4,206
  • 19
  • 52
  • 64
13
votes
4 answers

How do I pass parameters to the File::Find subroutine that processes each file?

Using File::Find, how can I pass parameters to the function that processes each file? I have a Perl script that traverses directories in order to convert some 3-channel TIFF files to JPEG files (3 JPEG files per TIFF file). This works, but I would…
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
6
votes
2 answers

When using Perl's File::Find what's a quick & easy way to limit search depth?

I want to be able to limit Perl's File::Find to a directory depth (below the specified search) to the specified directory and 1 & 2 subdirectories beneath it. I want to be able to enumerate the files at the same time, if this is possible. It must…
unixman83
  • 9,421
  • 10
  • 68
  • 102
6
votes
3 answers

Find all files containing the filename of specific date range on Terminal/Linux

I have a surveillance camera which is capturing image base on my given condition. The images are saved on my Linux. Image naming convention are given below- CAPTURE04.YYYYMMDDHHMMSS.jpg The directory contains the following files -…
Sharif
  • 623
  • 4
  • 12
6
votes
3 answers

How can I pass a parameter to the wanted function when using Perl's File::Find?

Possible Duplicate: How do I pass parameters to the File::Find subroutine that processes each file? One can use Perl's File::Find module like this: find( \&wanted, @directories); How can we add a parameter to the wanted function? For example, I…
jojo
  • 3,614
  • 1
  • 25
  • 21
6
votes
2 answers

File::Find::Rule and file separator

I am using File::Find::Rule on Strawberry Perl Windows. when I run the following code: @files = File::Find::Rule->file() ->in( $dir ); foreach my $file (@files){ …
smith
  • 3,232
  • 26
  • 55
5
votes
6 answers

How can I break out of recursive find function once a specific file is found?

I'm using the File::Find module to traverse a directory tree. Once I find a specific file, I want to stop searching. How can I do that? find (\$processFile, $mydir); sub processFile() { if ($_ =~ /target/) { # How can I…
MCS
  • 22,113
  • 20
  • 62
  • 76
5
votes
2 answers

How can I use File::Find to print files with the relative path only?

I am using File::Find in the code below to find the files from /home/user/data path. use File::Find; my $path = "/home/user/data"; chdir($path); my @files; find(\&d, "$path"); foreach my $file (@files) { print "$file\n"; } sub d { -f and -r and…
Space
  • 7,049
  • 6
  • 49
  • 68
4
votes
1 answer

Perl File::Find::Rule excluding directories from an array

I have a set of directories in an array as chdir /tmp; my @dir=("test" "abc" "def") I am looking for a way using File::Find::Rule to find all files in /tmp recursively, but excluding files from the ones in @dir. I could get all files from @dir by…
nohup
  • 3,105
  • 3
  • 27
  • 52
4
votes
2 answers

How can I make Perl's File::Find faster?

I have a folder named Lib and I am using the File::Find module to search that folder in whole dir say, D:\. It's taking a long time to search, say even 5 mins if the drive has a lot of subdirectories. How can I search that Lib faster so it will be…
User1611
  • 1,081
  • 4
  • 18
  • 27
4
votes
1 answer

Reading Files from Network Drives in Perl

I am working on a perl script which does a document inventory for pdfs in all directories starting from some root directory on our network. The script runs fine locally, but I can't get it to read files from the network drive. i have…
user1671813
  • 63
  • 1
  • 5
3
votes
2 answers

Perl File::Find: First list all files in directory and then jump to next dir?

I want to (by using File::Find) first list all files in current directory, and after that jump to a subdirectory. Is it possible?
marverix
  • 7,184
  • 6
  • 38
  • 50
3
votes
2 answers

Yii2: Finding file and getting path in a directory tree

I'm trying to search for a single filename in a bunch of directories and returning its path. I thought FileHelper::findFiles() would be a helping hand but it seems it doesn't accept a filename to search for but just a particular root directory and…
Antonio López
  • 386
  • 6
  • 22
3
votes
2 answers

Is there a cleaner way for File::Find to return a list of wanted files?

I find the design choice behind File::Find::find a little surprising. The examples I've come across all show find used in void context. The documentation also clarifies that the \&wanted coderef in find( \&wanted, @dirs ) is not meant to be a filter…
Zaid
  • 36,680
  • 16
  • 86
  • 155
2
votes
2 answers

File::Find::Rule::LibMagic: Is it ok to keep options with undefined values?

Is it OK to keep options with undefined values (in this case 'maxdepth')? #!/usr/bin/env perl use warnings; use 5.012; use File::Find::Rule::LibMagic qw(find); use Getopt::Long qw(GetOptions); my $max_depth; GetOptions ( 'max-depth=i' =>…
sid_com
  • 24,137
  • 26
  • 96
  • 187
1
2 3