Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to find if a file exists on windows .... ?

Posted on 2004-11-10
6
Medium Priority
?
240 Views
Last Modified: 2010-04-17
Hi gurus -

OK I am using File::Find to check a directory for files - but I want to give an error if there are no files there -

The problem is I get $file = . - regardless of whether there is a file there or not !

I have  tried using -e ...

any ideas guys ??

cheers

 Rab
0
Comment
Question by:rab54
5 Comments
 
LVL 2

Expert Comment

by:kjayaraman
ID: 12544085
I think you can find the number of files in the directory to check if there are any files.

Use this link for more info:
http://www.codeguru.com/forum/showthread.php?t=312458
0
 
LVL 1

Expert Comment

by:foodlebardle
ID: 12546086
Is that perl?
If so, is it a requirement that the solution be in perl?
0
 

Author Comment

by:rab54
ID: 12546946
The link above isn't in perl - but it is perl that I need ....

Anyway after further investigation - the problem is differentiating between the CWD (eg '.' ) and actual filenames -

If I loop thro all the files I get
.
..
test.txt

I need to say if it is '.' or '..' (without quotes ;~)  - then give me a error message -
I have tried reg exes and also code like -

if (($file ne ".") || ($files ne "..") - blah

But none of it seems to work ....

any ideas would be great .....

cheers

 rab






0
 

Author Comment

by:rab54
ID: 12568156
OK Sorted -

As . and .. are always present - it means if the count is < 3 there is no file !

cheers all

rab
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12857850
PAQed with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question