Jump to content
Debdatta Sen

Get of files containing filenames only from a given directory

Recommended Posts

Hi,

 

Let's say I am in directory C:\Test
This directory contains many different files including some H3D Files.
I want to create a list containing the names of these files only.

What is the best way to go about it?

Using 'ls' or 'system' can be used with the wildcards, but returns a lot of unwanted information as a string.
It is not very eays to filter this output.

 

I am looking for a command similar to 'glob' in TCL.

All I want is a list of files containing a specific extension to be returned.

Share this post


Link to post
Share on other sites

If you are already in the directory where you should look for the H3D files, you may use the function dir followed by .h3d extension:

     myfiles = dir('*.h3d')

It will return a list of .h3d files.

     length(myfiles) --> total number of .h3d files

     myfiles(i).name --> access to the .h3d file name according to the index i, which ranges from 1 to the number of files

And other details about these files are also available, such as date of creation, size etc.

Regards

Debdatta Sen likes this

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...