Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Can I test to see if filename exists without opening the file?

Subject: Can I test to see if filename exists without opening the file?

From: mpalmer@lmi.net

Date: 1 Jun, 2009 20:42:03

Message: 1 of 5

Can I test to see if the name of a file exists in a folder without having to try and open it?

Right now, the only way I know to test if a file exists is:

[fid mess] = fopen(fx);
if fid ~= -1
file exists
end

The problem with this is I have thousands of files to test, and I don't want to slow things down opening a bunch of files just to see if their name exists.

Subject: Can I test to see if filename exists without opening the file?

From: Steven Lord

Date: 1 Jun, 2009 21:02:22

Message: 2 of 5


<mpalmer@lmi.net> wrote in message
news:23848073.573.1243888953327.JavaMail.jakarta@nitrogen.mathforum.org...
> Can I test to see if the name of a file exists in a folder without having
> to try and open it?
>
> Right now, the only way I know to test if a file exists is:
>
> [fid mess] = fopen(fx);
> if fid ~= -1
> file exists
> end
>
> The problem with this is I have thousands of files to test, and I don't
> want to slow things down opening a bunch of files just to see if their
> name exists.

HELP EXIST.

--
Steve Lord
slord@mathworks.com

Subject: Can I test to see if filename exists without opening the file?

From: Peter

Date: 1 Jun, 2009 21:03:53

Message: 3 of 5

On Jun 1, 1:42 pm, "mpal...@lmi.net" <mpal...@lmi.net> wrote:
> Can I test to see if the name of a file exists in a folder without having to try and open it?
>
> Right now, the only way I know to test if a file exists is:
>
> [fid mess] = fopen(fx);
> if fid ~= -1
> file exists
> end
>
> The problem with this is I have thousands of files to test, and I don't want to slow things down opening a bunch of files just to see if their name exists.

help exist

Subject: Can I test to see if filename exists without opening the file?

From: mpalmer@lmi.net

Date: 1 Jun, 2009 21:30:32

Message: 4 of 5

Thanks, I will check it out.

Subject: Can I test to see if filename exists without opening the file?

From: Kian

Date: 1 Jun, 2009 22:36:01

Message: 5 of 5

exist('filename.ext', 'file')

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us